diff options
| author | 2024-09-09 11:13:09 -0400 | |
|---|---|---|
| committer | 2024-09-09 11:13:09 -0400 | |
| commit | d6c203a04e938b4946342ea31665a9a0e32f7281 (patch) | |
| tree | 27619a9bffd2bc5e80277a8e59e54608d12e9201 | |
| parent | added stripping of escape sequences from prompt size to allow for coloring (diff) | |
fixed wrapping bug due to not using updated prompt_length
Diffstat (limited to '')
| -rw-r--r-- | src/lush.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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"); } |
