Detect invalid coordinates in selection_from_string

Fixes #1751
This commit is contained in:
Maxime Coste 2017-12-12 18:08:40 +11:00
parent cb2ff7eb5f
commit ce2c0e54f4

View File

@ -498,6 +498,10 @@ Selection selection_from_string(StringView desc)
BufferCoord cursor{str_to_int({comma+1, dot_cursor}) - 1,
str_to_int({dot_cursor+1, desc.end()}) - 1};
if (anchor.line < 0 or anchor.column < 0 or
cursor.line < 0 or cursor.column < 0)
throw runtime_error(format("coordinates must be >= 1: '{}'", desc));
return Selection{anchor, cursor};
}