From d6c203a04e938b4946342ea31665a9a0e32f7281 Mon Sep 17 00:00:00 2001 From: BanceDev Date: Mon, 9 Sep 2024 11:13:09 -0400 Subject: fixed wrapping bug due to not using updated prompt_length --- src/lush.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lush.c b/src/lush.c index e5571f2..c97b956 100644 --- a/src/lush.c +++ b/src/lush.c @@ -363,7 +363,8 @@ char *lush_read_line() { { int width = get_terminal_width(); char *prompt = get_prompt(); - if ((strlen(prompt) + pos) % width == width - 2) { + size_t prompt_length = get_stripped_length(prompt); + if ((prompt_length + pos) % width == width - 2) { printf("\033[B"); } if (pos < strlen(buffer)) { @@ -378,7 +379,8 @@ char *lush_read_line() { { int width = get_terminal_width(); char *prompt = get_prompt(); - if ((strlen(prompt) + pos) % width == width - 1) { + size_t prompt_length = get_stripped_length(prompt); + if ((prompt_length + pos) % width == width - 1) { printf("\033[A"); } @@ -429,7 +431,8 @@ char *lush_read_line() { // handle edge case where cursor should be moved down int width = get_terminal_width(); char *prompt = get_prompt(); - if ((strlen(prompt) + pos) % width == width - 1 && + size_t prompt_length = get_stripped_length(prompt); + if ((prompt_length + pos) % width == width - 1 && pos < strlen(buffer)) { printf("\033[B"); } -- cgit v1.2.3-59-g8ed1b