tDo not allow navigating right past end of file - ve - a minimal text editor (w… | |
git clone git://src.adamsgaard.dk/ve | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit d459a5c2e81581c2019aa6ef69c99bc08d8180f2 | |
parent eb5c375b6985de714e2487c22e248171a8d2c926 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Tue, 6 Aug 2019 13:28:46 +0200 | |
Do not allow navigating right past end of file | |
Diffstat: | |
M input.c | 3 ++- | |
1 file changed, 2 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/input.c b/input.c | |
t@@ -33,7 +33,8 @@ editor_move_cursor(char key) | |
row = (E.cursor_y >= E.num_rows) ? NULL : &E.row[E.cur… | |
if (row && E.cursor_x < row->size) { | |
E.cursor_x++; | |
- } else if (row && E.cursor_x == row->size) { | |
+ } else if (row && E.cursor_x == row->size && | |
+ E.cursor_y < E.num_rows - 1) { | |
E.cursor_y++; | |
E.cursor_x = 0; | |
} |