Fix indent left line selection

(cherry picked from commit 2c64008718)
This commit is contained in:
Koala 2021-04-25 20:59:37 +01:00 committed by Rémi Verschelde
parent cc83557716
commit d08666f999
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -2102,6 +2102,7 @@ void TextEdit::indent_left() {
if (is_selection_active() && get_selection_to_column() == 0) { if (is_selection_active() && get_selection_to_column() == 0) {
end_line--; end_line--;
} }
String first_line_text = get_line(start_line);
String last_line_text = get_line(end_line); String last_line_text = get_line(end_line);
for (int i = start_line; i <= end_line; i++) { for (int i = start_line; i <= end_line; i++) {
@ -2126,11 +2127,18 @@ void TextEdit::indent_left() {
} }
} }
// Fix selection and cursor being off by one on the last line. if (is_selection_active()) {
if (is_selection_active() && last_line_text != get_line(end_line)) { // Fix selection being off by one on the first line.
if (first_line_text != get_line(start_line)) {
select(selection.from_line, selection.from_column - removed_characters, select(selection.from_line, selection.from_column - removed_characters,
selection.to_line, initial_selection_end_column);
}
// Fix selection being off by one on the last line.
if (last_line_text != get_line(end_line)) {
select(selection.from_line, selection.from_column,
selection.to_line, initial_selection_end_column - removed_characters); selection.to_line, initial_selection_end_column - removed_characters);
} }
}
cursor_set_column(initial_cursor_column - removed_characters, false); cursor_set_column(initial_cursor_column - removed_characters, false);
end_complex_operation(); end_complex_operation();
update(); update();