From 0ec71db3d3697f9af459d4b4e341e7ce8feef7b5 Mon Sep 17 00:00:00 2001 From: BanceDev Date: Mon, 9 Sep 2024 11:46:35 -0400 Subject: fixed line wrapping when deleting inline --- src/lush.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/lush.c b/src/lush.c index c97b956..c117fc2 100644 --- a/src/lush.c +++ b/src/lush.c @@ -411,6 +411,14 @@ char *lush_read_line() { memmove(&buffer[pos - 1], &buffer[pos], strlen(&buffer[pos]) + 1); pos--; + // handle edge case where cursor should be moved down + int width = get_terminal_width(); + char *prompt = get_prompt(); + size_t prompt_length = get_stripped_length(prompt); + if ((prompt_length + pos) % width == width - 2 && + pos < strlen(buffer)) { + printf("\033[A"); + } // if modifying text reset history history_pos = -1; reprint_buffer(buffer, &last_lines, &pos, history_pos); -- cgit v1.2.3-59-g8ed1b