diff --git a/CHANGELOG.md b/CHANGELOG.md index cc7de95697e..04596ceaffc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,7 +95,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, #6779, #6780, #6822) +- Dev: Added experimental spell checker support. (#6446, #6703, #6722, #6730, #6731, #6779, #6780, #6822, #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) diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 5eaef7dfb4f..f610b8dcf41 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -388,6 +388,10 @@ class Settings "/behaviour/spellChecking/defaultDictionary", "", }; + IntSetting nSpellCheckingSuggestions = { + "/behaviour/spellChecking/suggestions/count", + -1, + }; FloatSetting pauseOnHoverDuration = {"/behaviour/pauseOnHoverDuration", 0}; EnumSetting pauseChatModifier = { diff --git a/src/widgets/settingspages/ExternalToolsPage.cpp b/src/widgets/settingspages/ExternalToolsPage.cpp index 102ff91221d..39ff38b2cef 100644 --- a/src/widgets/settingspages/ExternalToolsPage.cpp +++ b/src/widgets/settingspages/ExternalToolsPage.cpp @@ -256,6 +256,17 @@ void ExternalToolsPage::initLayout(GeneralPageView &layout) ->setTooltip("Check the spelling of words in the input box of all " "splits by default.") ->addTo(layout); + 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 = [](const DictionaryInfo &dict) -> std::pair { diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 305bfa1bec8..f665488463c 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -39,6 +39,7 @@ #include #include +#include using namespace Qt::Literals; @@ -801,7 +802,13 @@ void SplitInput::installTextEditEvents() }); menu->addAction(spellcheckAction); - if (!this->inputHighlighter) + int nSuggestions = getSettings()->nSpellCheckingSuggestions; + if (nSuggestions < 0) + { + nSuggestions = std::numeric_limits::max(); + } + + if (!this->inputHighlighter || nSuggestions == 0) { return; } @@ -822,7 +829,8 @@ void SplitInput::installTextEditEvents() auto suggestions = getApp()->getSpellChecker()->suggestions(word.toString()); - 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 {