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;