mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
HackStudio: Allow toggling between simple and semantic highlighting
Until it becomes enough stable and performant, semantic highlighting is disabled by default. It can be toggled on via the "Project" menu in HackStudio.
This commit is contained in:
parent
81dcf6c58b
commit
8ec4328fcb
4 changed files with 33 additions and 8 deletions
|
@ -480,8 +480,8 @@ void Editor::set_document(GUI::TextDocument& doc)
|
|||
|
||||
auto& code_document = static_cast<CodeDocument&>(doc);
|
||||
|
||||
set_syntax_highlighter_for(code_document);
|
||||
set_language_client_for(code_document);
|
||||
set_syntax_highlighter_for(code_document);
|
||||
|
||||
if (m_language_client) {
|
||||
set_autocomplete_provider(make<LanguageServerAidedAutocompleteProvider>(*m_language_client));
|
||||
|
@ -500,9 +500,6 @@ void Editor::set_document(GUI::TextDocument& doc)
|
|||
} else {
|
||||
set_autocomplete_provider_for(code_document);
|
||||
}
|
||||
|
||||
on_token_info_timer_tick();
|
||||
m_tokens_info_timer->restart();
|
||||
}
|
||||
|
||||
Optional<Editor::AutoCompleteRequestData> Editor::get_autocomplete_request_data()
|
||||
|
@ -609,7 +606,13 @@ void Editor::set_syntax_highlighter_for(const CodeDocument& document)
|
|||
{
|
||||
switch (document.language()) {
|
||||
case Language::Cpp:
|
||||
set_syntax_highlighter(make<Cpp::SemanticSyntaxHighlighter>());
|
||||
if (m_use_semantic_syntax_highlighting) {
|
||||
set_syntax_highlighter(make<Cpp::SemanticSyntaxHighlighter>());
|
||||
on_token_info_timer_tick();
|
||||
m_tokens_info_timer->restart();
|
||||
} else
|
||||
set_syntax_highlighter(make<Cpp::SyntaxHighlighter>());
|
||||
|
||||
break;
|
||||
case Language::CSS:
|
||||
set_syntax_highlighter(make<Web::CSS::SyntaxHighlighter>());
|
||||
|
@ -638,6 +641,8 @@ void Editor::set_syntax_highlighter_for(const CodeDocument& document)
|
|||
default:
|
||||
set_syntax_highlighter({});
|
||||
}
|
||||
|
||||
force_rehighlight();
|
||||
}
|
||||
|
||||
void Editor::set_autocomplete_provider_for(CodeDocument const& document)
|
||||
|
@ -754,4 +759,10 @@ void Editor::create_tokens_info_timer()
|
|||
m_tokens_info_timer->start();
|
||||
}
|
||||
|
||||
void Editor::set_semantic_syntax_highlighting(bool value)
|
||||
{
|
||||
m_use_semantic_syntax_highlighting = value;
|
||||
set_syntax_highlighter_for(code_document());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue