From e6248cf7be1b20d5a2ff153d8cf5c0ec52931ab4 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 29 Feb 2020 09:43:26 +0100 Subject: [PATCH] Fix selection going out of bounds Which happened when starting the selection at the end of the commandline. In this case, selections still interact weirdly with autosuggestions (the first character of the suggestion appears to be part of the selection when it's not). Fixes #6680 (cherry-picked from commit 99851c09b31f5e5478b9c1a2197606f9676dcfc2) --- src/reader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reader.cpp b/src/reader.cpp index 970ebfb74..e33fb8416 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -3477,7 +3477,7 @@ bool reader_get_selection(size_t *start, size_t *len) { reader_data_t *data = current_data_or_null(); if (data != nullptr && data->sel_active) { *start = data->sel_start_pos; - *len = std::min(data->sel_stop_pos - data->sel_start_pos, data->command_line.size()); + *len = std::min(data->sel_stop_pos, data->command_line.size()) - data->sel_start_pos; result = true; } return result;