From 98a98b14249f3f4a94a3b0e32c6c11c564915609 Mon Sep 17 00:00:00 2001 From: Ray Hogenson Date: Fri, 15 Nov 2019 18:34:27 -0800 Subject: [PATCH] Change vi selection mode to be inclusive The current cursor position should be included in the selection to be consistent with the behavior of vi. Fixes #5770 --- src/reader.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index 1d535278a..79e5346fe 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -594,10 +594,10 @@ void reader_data_t::update_buff_pos(editable_line_t *el, size_t buff_pos) { if (el == &command_line && sel_active) { if (sel_begin_pos <= buff_pos) { sel_start_pos = sel_begin_pos; - sel_stop_pos = buff_pos; + sel_stop_pos = buff_pos + 1; } else { sel_start_pos = buff_pos; - sel_stop_pos = sel_begin_pos; + sel_stop_pos = sel_begin_pos + 1; } } } @@ -3095,11 +3095,12 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat case rl::begin_selection: case rl::end_selection: { sel_start_pos = command_line.position; - sel_stop_pos = command_line.position; if (c == rl::begin_selection) { + sel_stop_pos = command_line.position + 1; sel_active = true; sel_begin_pos = command_line.position; } else { + sel_stop_pos = command_line.position; sel_active = false; }