From e65976f6d15c798d76fc291444341532d7415862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Nephtali?= Date: Thu, 13 Apr 2017 20:43:27 +0200 Subject: [PATCH] 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. --- tte.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tte.c b/tte.c index 833eec4..7ed45d7 100644 --- a/tte.c +++ b/tte.c @@ -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;