From 8bb4d466761f5d71202652dbbfb6ef0e22cd0a05 Mon Sep 17 00:00:00 2001 From: Itamar Date: Sat, 12 Feb 2022 11:20:25 +0200 Subject: [PATCH] HackStudio: Only query token information if semantic highlighting is on --- Userland/DevTools/HackStudio/Editor.cpp | 2 ++ Userland/DevTools/HackStudio/HackStudio.h | 1 + Userland/DevTools/HackStudio/HackStudioWidget.cpp | 9 ++++++++- Userland/DevTools/HackStudio/HackStudioWidget.h | 2 ++ Userland/DevTools/HackStudio/main.cpp | 5 +++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index f077e7e583..f0472977e3 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -733,6 +733,8 @@ void Editor::set_debug_mode(bool enabled) void Editor::on_token_info_timer_tick() { + if (!semantic_syntax_highlighting_is_enabled()) + return; if (!m_language_client || !m_language_client->is_active_client()) return; diff --git a/Userland/DevTools/HackStudio/HackStudio.h b/Userland/DevTools/HackStudio/HackStudio.h index 962c9d3b69..16392de9f8 100644 --- a/Userland/DevTools/HackStudio/HackStudio.h +++ b/Userland/DevTools/HackStudio/HackStudio.h @@ -22,6 +22,7 @@ Project& project(); String currently_open_file(); void set_current_editor_wrapper(RefPtr); void for_each_open_file(Function); +bool semantic_syntax_highlighting_is_enabled(); class Locator; Locator& locator(); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index de9cc2a485..336010d987 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -1166,7 +1166,9 @@ void HackStudioWidget::create_project_menu(GUI::Window& window) new_submenu.add_action(*m_new_plain_file_action); new_submenu.add_separator(); new_submenu.add_action(*m_new_directory_action); - project_menu.add_action(create_toggle_syntax_highlighting_mode_action()); + + m_toggle_semantic_highlighting_action = create_toggle_syntax_highlighting_mode_action(); + project_menu.add_action(*m_toggle_semantic_highlighting_action); } void HackStudioWidget::create_edit_menu(GUI::Window& window) @@ -1536,4 +1538,9 @@ NonnullRefPtr HackStudioWidget::create_toggle_syntax_highlighting_m return action; } +bool HackStudioWidget::semantic_syntax_highlighting_is_enabled() const +{ + return m_toggle_semantic_highlighting_action->is_checked(); +} + } diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.h b/Userland/DevTools/HackStudio/HackStudioWidget.h index 07929f4d87..0c2550f1db 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.h +++ b/Userland/DevTools/HackStudio/HackStudioWidget.h @@ -71,6 +71,7 @@ public: void open_coredump(String const& coredump_path); void for_each_open_file(Function); + bool semantic_syntax_highlighting_is_enabled() const; private: static String get_full_path_of_serenity_source(const String& file); @@ -217,6 +218,7 @@ private: RefPtr m_run_action; RefPtr m_locations_history_back_action; RefPtr m_locations_history_forward_action; + RefPtr m_toggle_semantic_highlighting_action; RefPtr read_editor_font_from_config(); void change_editor_font(RefPtr); diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp index 7f32222f1e..d2c71ba06d 100644 --- a/Userland/DevTools/HackStudio/main.cpp +++ b/Userland/DevTools/HackStudio/main.cpp @@ -173,4 +173,9 @@ void for_each_open_file(Function func) s_hack_studio_widget->for_each_open_file(move(func)); } +bool semantic_syntax_highlighting_is_enabled() +{ + return s_hack_studio_widget->semantic_syntax_highlighting_is_enabled(); +} + }