aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/line/cursor.cc4
-rw-r--r--src/line/getter.cc2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/line/cursor.cc b/src/line/cursor.cc
index b44054e..4b51d04 100644
--- a/src/line/cursor.cc
+++ b/src/line/cursor.cc
@@ -123,7 +123,7 @@ void move_cursor(T_cursor_movement_direction d)
{
case T_cursor_movement_direction::LEFT:
// if cursor is not at left margin
- if (prompt_pos < get_terminal_pos_cursor())
+ if (prompt_pos+1 < get_terminal_pos_cursor())
{
buffer_index_cursor--;
print("\x1b[D"); fflush(stdout); // move cursor to the left
@@ -144,7 +144,7 @@ void move_cursor(T_cursor_movement_direction d)
{
// already at the end of buffer
if (buffer_index_cursor == line_buffer.size()) break;
-
+
buffer_index_cursor++;
print("\x1b[C"); fflush(stdout); // move cursor to the right
}
diff --git a/src/line/getter.cc b/src/line/getter.cc
index 73b0c03..f396ce1 100644
--- a/src/line/getter.cc
+++ b/src/line/getter.cc
@@ -18,7 +18,7 @@ namespace ov4
int get_terminal_pos_cursor()
{
- return prompt_pos + buffer_index_cursor;
+ return prompt_pos + (buffer_index_cursor - get_buffer_index_display_begin()) + 1;
}
int get_buffer_index_display_begin()