Fix a crash when using the arrow keys while searching

If the query is not found, using the left or up arrow key leads to a crash.
This commit is contained in:
Aurélien Nephtali committed 2017-04-13 20:43:27 +02:00
1 parent e35254143e
commit e65976f6d1
1 file changed
+4
+4
View File
@@ -1151,6 +1151,10 @@ void editorSearchCallback(char* query, int key) {
} else if (key == ARROW_RIGHT || key == ARROW_DOWN) {
direction = 1;
} else if (key == ARROW_LEFT || key == ARROW_UP) {
if (last_match == -1) {
// If nothing matched and the left or up arrow key was pressed
return;
}
direction = -1;
} else {
last_match = -1;