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
This commit is contained in:
Ray Hogenson 2019-11-15 18:34:27 -08:00 committed by Fabian Homborg
parent cb72a33e0c
commit 98a98b1424

View file

@ -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;
}