From 791e881892c7fa55b4f4ed5b885ac3f156276ca2 Mon Sep 17 00:00:00 2001 From: SimonFJ20 Date: Wed, 13 Apr 2022 16:14:59 +0200 Subject: [PATCH] LibGUI: Rename function to make intention clearer --- Userland/DevTools/Playground/main.cpp | 2 +- Userland/Libraries/LibGUI/TextEditor.cpp | 4 ++-- Userland/Libraries/LibGUI/TextEditor.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/DevTools/Playground/main.cpp b/Userland/DevTools/Playground/main.cpp index 2be6b6f020..57e374fe35 100644 --- a/Userland/DevTools/Playground/main.cpp +++ b/Userland/DevTools/Playground/main.cpp @@ -227,7 +227,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(edit_menu->try_add_action(GUI::Action::create("&Format GML", { Mod_Ctrl | Mod_Shift, Key_I }, [&](auto&) { auto formatted_gml_or_error = GUI::GML::format_gml(editor->text()); if (!formatted_gml_or_error.is_error()) { - editor->replace_all_text_while_keeping_undo_stack(formatted_gml_or_error.release_value()); + editor->replace_all_text_without_resetting_undo_stack(formatted_gml_or_error.release_value()); } else { GUI::MessageBox::show( window, diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 0ea96cc616..93cf86c055 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -1446,14 +1446,14 @@ void TextEditor::insert_at_cursor_or_replace_selection(StringView text) } } -void TextEditor::replace_all_text_while_keeping_undo_stack(StringView text) +void TextEditor::replace_all_text_without_resetting_undo_stack(StringView text) { auto start = GUI::TextPosition(0, 0); auto last_line_index = line_count() - 1; auto end = GUI::TextPosition(last_line_index, line(last_line_index).length()); auto range = GUI::TextRange(start, end); auto normalized_range = range.normalized(); - execute(text, range); + execute(text, range, "GML Playground Format Text"); did_change(); set_cursor(normalized_range.start()); update(); diff --git a/Userland/Libraries/LibGUI/TextEditor.h b/Userland/Libraries/LibGUI/TextEditor.h index cb4d2f58ff..1bd5b1401a 100644 --- a/Userland/Libraries/LibGUI/TextEditor.h +++ b/Userland/Libraries/LibGUI/TextEditor.h @@ -123,7 +123,7 @@ public: TextRange normalized_selection() const { return m_selection.normalized(); } void insert_at_cursor_or_replace_selection(StringView); - void replace_all_text_while_keeping_undo_stack(StringView text); + void replace_all_text_without_resetting_undo_stack(StringView text); bool write_to_file(String const& path); bool write_to_file(Core::File&); bool has_selection() const { return m_selection.is_valid(); }