1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:07:34 +00:00

HackStudio: Do not create a new LanguageClient unless needed

Previously, whenever Editor::set_document() was called, we destroyed
the previous LanguageClient instance of the editor and created a new
one.

We now check if the language of the existing LanguageClient matches the
new document, and if so we do not create a new LanguageClient instance.

This fixes an issue where doing "goto definition" would crash
HackStudio. This was probably introduced in 44418cb351.

The crash occurred because when doing "goto definition", we called a
AK::Function callback from the LanguageClient, which internally called
Editor::set_document().

Editor::set_document() destroyed the existing LanguageClient, which
cased a VERIFY in Function::clear() to fail because we were trying to
destroy the AK::Function object while executing inside it.
This commit is contained in:
Itamar 2021-06-25 12:39:37 +03:00 committed by Andreas Kling
parent 7331b74731
commit e16c24bb95
2 changed files with 44 additions and 22 deletions

View file

@ -92,6 +92,8 @@ private:
Optional<AutoCompleteRequestData> get_autocomplete_request_data();
void flush_file_content_to_langauge_server();
void set_syntax_highlighter_for(const CodeDocument&);
void set_language_client_for(const CodeDocument&);
explicit Editor();