From c0f1b8f1413ec487281de1e723f1f33b1e69e789 Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Sun, 18 Jan 2026 22:23:56 +0100 Subject: [PATCH 1/5] chore(spellcheck): add option to toggle suggestions --- src/singletons/Settings.hpp | 4 ++++ src/widgets/settingspages/ExternalToolsPage.cpp | 5 +++++ src/widgets/splits/SplitInput.cpp | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 7ea15869cb2..45b751ed2ba 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -365,6 +365,10 @@ class Settings "/behaviour/spellChecking/defaultDictionary", "", }; + BoolSetting showSpellCheckingSuggestions = { + "/behaviour/spellChecking/suggestions/enabled", + true, + }; FloatSetting pauseOnHoverDuration = {"/behaviour/pauseOnHoverDuration", 0}; EnumSetting pauseChatModifier = { diff --git a/src/widgets/settingspages/ExternalToolsPage.cpp b/src/widgets/settingspages/ExternalToolsPage.cpp index 102ff91221d..0ca0474b4e1 100644 --- a/src/widgets/settingspages/ExternalToolsPage.cpp +++ b/src/widgets/settingspages/ExternalToolsPage.cpp @@ -256,6 +256,11 @@ void ExternalToolsPage::initLayout(GeneralPageView &layout) ->setTooltip("Check the spelling of words in the input box of all " "splits by default.") ->addTo(layout); + SettingWidget::checkbox("Show suggestions in context menu", + s.showSpellCheckingSuggestions) + ->setTooltip("When enabled, right clicking any word in the input " + "box will show alternatives.") + ->addTo(layout); auto toItem = [](const DictionaryInfo &dict) -> std::pair { diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 745f0062682..b9a89bc02ec 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -787,7 +787,7 @@ void SplitInput::installTextEditEvents() auto cursor = this->ui_.textEdit->cursorForPosition(pos); cursor.select(QTextCursor::WordUnderCursor); auto word = cursor.selectedText(); - if (!word.isEmpty()) + if (!word.isEmpty() && getSettings()->showSpellCheckingSuggestions) { auto suggestions = getApp()->getSpellChecker()->suggestions(word); From 6545ec8bda42c69a7be48497b723032510c6711e Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Sun, 18 Jan 2026 22:26:44 +0100 Subject: [PATCH 2/5] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c938bc5c75..d188b46a613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,7 +79,7 @@ - Dev: Unwrapped `LimitedQueueSnapshot` to `std::vector`. (#6606) - Dev: Simplified uses of `getMessageSnapshot`. (#6607) - Dev: Disabled `llvm-prefer-static-over-anonymous-namespace` in clang-tidy. (#6610) -- Dev: Added experimental spell checker support. (#6446, #6703, #6722, #6730, #6731) +- Dev: Added experimental spell checker support. (#6446, #6703, #6722, #6730, #6731, #6751) - Dev: Added Clazy linting in CI. (#6623) - Dev: Added custom clang-tidy module linting in CI. (#6626) - Dev: CMake option `USE_ALTERNATE_LINKER` now errors if the given linker can't be found. (#6692) From e376ffc6cf67faa0f8e884d8b162aa942dff2f9c Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Sat, 28 Feb 2026 12:05:29 +0100 Subject: [PATCH 3/5] fix: use limit on suggestions instead of on/off --- src/singletons/Settings.hpp | 6 +++--- src/widgets/settingspages/ExternalToolsPage.cpp | 14 ++++++++++---- src/widgets/splits/SplitInput.cpp | 12 ++++++++++-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 7a798d27bf0..f610b8dcf41 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -388,9 +388,9 @@ class Settings "/behaviour/spellChecking/defaultDictionary", "", }; - BoolSetting showSpellCheckingSuggestions = { - "/behaviour/spellChecking/suggestions/enabled", - true, + IntSetting nSpellCheckingSuggestions = { + "/behaviour/spellChecking/suggestions/count", + -1, }; FloatSetting pauseOnHoverDuration = {"/behaviour/pauseOnHoverDuration", 0}; diff --git a/src/widgets/settingspages/ExternalToolsPage.cpp b/src/widgets/settingspages/ExternalToolsPage.cpp index 0ca0474b4e1..39ff38b2cef 100644 --- a/src/widgets/settingspages/ExternalToolsPage.cpp +++ b/src/widgets/settingspages/ExternalToolsPage.cpp @@ -256,10 +256,16 @@ void ExternalToolsPage::initLayout(GeneralPageView &layout) ->setTooltip("Check the spelling of words in the input box of all " "splits by default.") ->addTo(layout); - SettingWidget::checkbox("Show suggestions in context menu", - s.showSpellCheckingSuggestions) - ->setTooltip("When enabled, right clicking any word in the input " - "box will show alternatives.") + SettingWidget::intInput("Number of suggestions in context menu", + s.nSpellCheckingSuggestions, + { + .min = -1, + .max = std::numeric_limits::max(), + }) + ->setTooltip( + "When right clicking any word, show this many suggestions. If " + "this is 0, no suggestions will be shown and if it's -1, no " + "limit is set.") ->addTo(layout); auto toItem = diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index ab6521c5eb7..647223140a8 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -804,11 +804,19 @@ void SplitInput::installTextEditEvents() auto cursor = this->ui_.textEdit->cursorForPosition(pos); cursor.select(QTextCursor::WordUnderCursor); auto word = cursor.selectedText(); - if (!word.isEmpty() && getSettings()->showSpellCheckingSuggestions) + + int nSuggestions = getSettings()->nSpellCheckingSuggestions; + if (nSuggestions < 0) + { + nSuggestions = std::numeric_limits::max(); + } + + if (!word.isEmpty() && nSuggestions != 0) { auto suggestions = getApp()->getSpellChecker()->suggestions(word); - for (const auto &sugg : suggestions) + for (const auto &sugg : + suggestions | std::views::take(nSuggestions)) { auto qSugg = QString::fromStdString(sugg); menu->addAction(qSugg, [this, qSugg, cursor]() mutable { From 9818d5e601f120940a6e6982ae204b3548b2aa19 Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Sat, 28 Feb 2026 12:32:34 +0100 Subject: [PATCH 4/5] fix: include ranges --- src/widgets/splits/SplitInput.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 647223140a8..f1b83e386d5 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -39,6 +39,7 @@ #include #include +#include using namespace Qt::Literals; From eb5823c262b1a6fc8a30188f703ce8b7aafbab56 Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Sat, 28 Feb 2026 13:08:13 +0100 Subject: [PATCH 5/5] fix: newline --- src/widgets/splits/SplitInput.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index b31be53c5a5..f665488463c 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -817,7 +817,6 @@ void SplitInput::installTextEditEvents() QString text = this->ui_.textEdit->toPlainText(); QStringView word = this->inputHighlighter->getWordAt(text, cursorAtPos.position()); - if (!word.isEmpty()) { auto cursor = this->ui_.textEdit->textCursor();