aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorJarno Mäkipää <jmakip87@gmail.com>2020-02-06 21:06:43 +0200
committerRob Landley <rob@landley.net>2020-02-06 21:11:59 -0600
commitdb188cde1f05ec42fd0c56bc9630788003708777 (patch)
tree2c339ce6274ae440e7c2d827ca6399632a03ff3f /toys
parent31711481dc06ab4b3068fc284529e0644b5e3673 (diff)
downloadtoybox-db188cde1f05ec42fd0c56bc9630788003708777.tar.gz
vi: fix pointer pos when at end of line
Going to $ made draw_page render cursor to wrong line
Diffstat (limited to 'toys')
-rw-r--r--toys/pending/vi.c4
1 files changed, 2 insertions, 2 deletions
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;
}