Restore cursor position when cancelling search

This commit is contained in:
Saumya Bhatnagar 2018-06-02 15:38:15 +05:30
parent 0a678b5400
commit ea53b4c5c1
2 changed files with 10 additions and 0 deletions

BIN
editor

Binary file not shown.

View File

@ -479,10 +479,20 @@ void editorFindCallback(char* query, int cur_key) {
}
void editorFind() {
int saved_cursorX = E.cursorX;
int saved_cursorY = E.cursorY;
int saved_colOff = E.colOff;
int saved_rowOff = E.rowOff;
char *query = editorPrompt("Search: %s (ESC to cancel)", editorFindCallback);
if (query) {
free(query);
} else {
E.cursorX = saved_cursorX;
E.cursorY = saved_cursorY;
E.colOff = saved_colOff;
E.rowOff = saved_rowOff;
}
}