From db188cde1f05ec42fd0c56bc9630788003708777 Mon Sep 17 00:00:00 2001 From: Jarno Mäkipää Date: Thu, 6 Feb 2020 21:06:43 +0200 Subject: vi: fix pointer pos when at end of line Going to $ made draw_page render cursor to wrong line --- toys/pending/vi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toys/pending/vi.c') diff --git a/toys/pending/vi.c b/toys/pending/vi.c index 5086a0da..c6f44ef6 100644 --- a/toys/pending/vi.c +++ b/toys/pending/vi.c @@ -418,9 +418,9 @@ static int text_codepoint(char *dest, size_t offset) static size_t text_sol(size_t offset) { size_t pos; - if (!TT.filesize) return 0; + if (!TT.filesize || !offset) return 0; else if (TT.filesize <= offset) return TT.filesize-1; - else if ((pos = text_strrchr(offset, '\n')) == SIZE_MAX) return 0; + else if ((pos = text_strrchr(offset-1, '\n')) == SIZE_MAX) return 0; else if (pos < offset) return pos+1; return offset; } -- cgit v1.2.3