Fix segfault on g. when last modification position past buffer end

This commit is contained in:
Maxime Coste 2015-06-18 19:51:04 +01:00
parent bf46870ff2
commit fce2a21690

View File

@ -230,7 +230,9 @@ void goto_commands(Context& context, NormalParams params)
{ {
context.push_jump(); context.push_jump();
auto pos = buffer.last_modification_coord(); auto pos = buffer.last_modification_coord();
if (buffer[pos.line].length() == pos.column + 1) if (pos >= buffer.back_coord())
pos = buffer.back_coord();
else if (buffer[pos.line].length() == pos.column + 1)
pos = ByteCoord{ pos.line+1, 0 }; pos = ByteCoord{ pos.line+1, 0 };
select_coord<mode>(buffer, pos, context.selections()); select_coord<mode>(buffer, pos, context.selections());
break; break;