diff options
author | iyush <aayushsharma889@gmail.com> | 2023-04-14 22:12:54 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-30 06:08:22 +0200 |
commit | a268dcb1e25541a571c43e27c2ed3de1bdcd7189 (patch) | |
tree | 5846a5a81f71a437d87e5d6624550249eb32bc17 /Userland/DevTools | |
parent | 4653b38808a3030f3e9308713704d40aff8e5d69 (diff) | |
download | serenity-a268dcb1e25541a571c43e27c2ed3de1bdcd7189.zip |
HackStudio: Move around execution order and prevent crashing
Previously hackstudio tried to synchronize the language server before
executing the command inside the editor. If sync-command for the server
(for example the CommentLineCommand) is not implemented inside the
function responsible for syncing the language server, the IDE would
crash.
This patch makes it such that the synchronization happens only after IDE
executes the command locally. If such command is not implemented (as
was the case earlier), it would simply reupdate the content inside the
language server. Even though the reupdate might be expensive, it is
better than crashing hackstudio altogether.
Because of reordering, the relevant function names have been changed to
better reflect the code flow.
Diffstat (limited to 'Userland/DevTools')
-rw-r--r-- | Userland/DevTools/HackStudio/Editor.cpp | 4 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/Editor.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index c846b340d8..1aa190ef41 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -542,7 +542,7 @@ void Editor::LanguageServerAidedAutocompleteProvider::provide_completions(Functi data.value().position.column()); } -void Editor::will_execute(GUI::TextDocumentUndoCommand const& command) +void Editor::after_execute(GUI::TextDocumentUndoCommand const& command) { if (!m_language_client) return; @@ -568,7 +568,7 @@ void Editor::will_execute(GUI::TextDocumentUndoCommand const& command) return; } - VERIFY_NOT_REACHED(); + flush_file_content_to_langauge_server(); } void Editor::undo() diff --git a/Userland/DevTools/HackStudio/Editor.h b/Userland/DevTools/HackStudio/Editor.h index 24f4180785..7c29ac6db4 100644 --- a/Userland/DevTools/HackStudio/Editor.h +++ b/Userland/DevTools/HackStudio/Editor.h @@ -50,7 +50,7 @@ public: CodeDocument& code_document(); virtual void set_document(GUI::TextDocument&) override; - virtual void will_execute(GUI::TextDocumentUndoCommand const&) override; + virtual void after_execute(GUI::TextDocumentUndoCommand const&) override; virtual void undo() override; virtual void redo() override; |