Small refactor

This commit is contained in:
Maxime Coste 2014-10-01 23:41:06 +01:00
parent cf01227e1c
commit fc53a80395

View File

@ -363,21 +363,6 @@ Selection select_paragraph(const Buffer& buffer, const Selection& selection, Obj
: Selection{last.coord(), first.coord()}; : Selection{last.coord(), first.coord()};
} }
static CharCount get_indent(const String& str, int tabstop)
{
CharCount indent = 0;
for (auto& c : str)
{
if (c == ' ')
++indent;
else if (c =='\t')
indent = (indent / tabstop + 1) * tabstop;
else
break;
}
return indent;
}
Selection select_whitespaces(const Buffer& buffer, const Selection& selection, ObjectFlags flags) Selection select_whitespaces(const Buffer& buffer, const Selection& selection, ObjectFlags flags)
{ {
auto is_whitespace = [&](char c) { auto is_whitespace = [&](char c) {
@ -407,6 +392,21 @@ Selection select_whitespaces(const Buffer& buffer, const Selection& selection, O
: utf8_range(last, first); : utf8_range(last, first);
} }
static CharCount get_indent(const String& str, int tabstop)
{
CharCount indent = 0;
for (auto& c : str)
{
if (c == ' ')
++indent;
else if (c =='\t')
indent = (indent / tabstop + 1) * tabstop;
else
break;
}
return indent;
}
static bool is_only_whitespaces(const String& str) static bool is_only_whitespaces(const String& str)
{ {
auto it = str.begin(); auto it = str.begin();