From 02e3e4ac9b2703a0a867211c2482eab257cbc311 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 1 Oct 2020 20:08:29 +0200 Subject: term: cursor-left: reduce move count by one when lcf=true When lcf is true, cursor is actually beyond the right margin, but the stored coordinate is at the margin. This means we need to reduce the number of cells to move the cursor by one. This fixes an issue where e.g. backspacing when the cursor is at the right margin erased the next-to-last character instead of the last character. --- terminal.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 0840a45c..97840824 100644 --- a/terminal.c +++ b/terminal.c @@ -1728,6 +1728,11 @@ term_cursor_home(struct terminal *term) void term_cursor_left(struct terminal *term, int count) { + if (unlikely(term->grid->cursor.lcf)) + count--; + + assert(count >= 0); + int move_amount = min(term->grid->cursor.point.col, count); term->grid->cursor.point.col -= move_amount; assert(term->grid->cursor.point.col >= 0); -- cgit v1.3