Merge pull request #87099 from bitwise-aiden/ba-add-trim-newlines

Implement `trim_final_newlines` setting and functionality
This commit is contained in:
Rémi Verschelde 2024-05-30 11:47:28 +02:00
commit 838eb5a0fd
No known key found for this signature in database
GPG key ID: C3336907360768E1
13 changed files with 99 additions and 4 deletions

View file

@ -1124,6 +1124,31 @@ void CodeTextEditor::trim_trailing_whitespace() {
}
}
void CodeTextEditor::trim_final_newlines() {
int final_line = text_editor->get_line_count() - 1;
int check_line = final_line;
String line = text_editor->get_line(check_line);
while (line.is_empty() && check_line > -1) {
--check_line;
line = text_editor->get_line(check_line);
}
++check_line;
if (check_line < final_line) {
text_editor->begin_complex_operation();
text_editor->remove_text(check_line, 0, final_line, 0);
text_editor->merge_overlapping_carets();
text_editor->end_complex_operation();
text_editor->queue_redraw();
}
}
void CodeTextEditor::insert_final_newline() {
int final_line = text_editor->get_line_count() - 1;
String line = text_editor->get_line(final_line);