summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/menu.c b/menu.c
index 6977552..dfb3db9 100644
--- a/menu.c
+++ b/menu.c
@@ -244,7 +244,9 @@ static void menu_update(Ted *ted) {
char *end;
long line_number = strtol(contents, &end, 0);
TextBuffer *buffer = ted->prev_active_buffer;
- if (line_number > 0 && *end == '\0' && line_number <= (long)buffer->nlines) {
+ if (*contents != '\0' && *end == '\0') {
+ if (line_number < 1) line_number = 1;
+ if (line_number > buffer->nlines) line_number = (long)buffer->nlines;
BufferPos pos = {(u32)line_number - 1, 0};
if (line_buffer->line_buffer_submitted) {