Fix spaces_to_tabs implementation accessing past end

Fixes #643
This commit is contained in:
Maxime Coste 2016-03-30 19:26:26 +01:00
parent 7dd05d675c
commit 5332378419
4 changed files with 6 additions and 2 deletions

View File

@ -1327,14 +1327,15 @@ void spaces_to_tabs(Context& context, NormalParams params)
auto spaces_beg = it;
auto spaces_end = spaces_beg+1;
CharCount col = get_column(buffer, opt_tabstop, spaces_end.coord());
while (*spaces_end == ' ' and (col % tabstop) != 0)
while (spaces_end != end and
*spaces_end == ' ' and (col % tabstop) != 0)
{
++spaces_end;
++col;
}
if ((col % tabstop) == 0)
spaces.push_back({spaces_beg.coord(), (spaces_end-1).coord()});
else if (*spaces_end == '\t')
else if (spaces_end != end and *spaces_end == '\t')
spaces.push_back({spaces_beg.coord(), spaces_end.coord()});
it = spaces_end;
}

View File

@ -0,0 +1 @@
gg2l<a-@>

View File

@ -0,0 +1 @@
hello

View File

@ -0,0 +1 @@
hello