aboutsummaryrefslogtreecommitdiffstats
path: root/src/lush.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lush.c')
-rw-r--r--src/lush.c8
1 files changed, 8 insertions, 0 deletions
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);