Skip to content

Commit

Permalink
Fix indent left line selection
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalasinTraffic committed Apr 25, 2021
1 parent 15a85fe commit 2c64008
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions scene/gui/text_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,7 @@ void TextEdit::indent_selected_lines_left() {
if (is_selection_active() && get_selection_to_column() == 0) {
end_line--;
}
String first_line_text = get_line(start_line);
String last_line_text = get_line(end_line);

for (int i = start_line; i <= end_line; i++) {
Expand All @@ -2078,10 +2079,17 @@ void TextEdit::indent_selected_lines_left() {
}
}

// Fix selection and cursor being off by one on the last line.
if (is_selection_active() && last_line_text != get_line(end_line)) {
select(selection.from_line, selection.from_column - removed_characters,
selection.to_line, initial_selection_end_column - removed_characters);
if (is_selection_active()) {
// 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,
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);
}
}
cursor_set_column(initial_cursor_column - removed_characters, false);
end_complex_operation();
Expand Down

0 comments on commit 2c64008

Please sign in to comment.