Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/singletons/Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ class Settings
"/behaviour/spellChecking/defaultDictionary",
"",
};
IntSetting nSpellCheckingSuggestions = {
"/behaviour/spellChecking/suggestions/count",
-1,
};

FloatSetting pauseOnHoverDuration = {"/behaviour/pauseOnHoverDuration", 0};
EnumSetting<Qt::KeyboardModifier> pauseChatModifier = {
Expand Down
11 changes: 11 additions & 0 deletions src/widgets/settingspages/ExternalToolsPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>::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<QString, QVariant> {
Expand Down
12 changes: 10 additions & 2 deletions src/widgets/splits/SplitInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <QSignalBlocker>

#include <functional>
#include <ranges>

using namespace Qt::Literals;

Expand Down Expand Up @@ -801,7 +802,13 @@ void SplitInput::installTextEditEvents()
});
menu->addAction(spellcheckAction);

if (!this->inputHighlighter)
int nSuggestions = getSettings()->nSpellCheckingSuggestions;
if (nSuggestions < 0)
{
nSuggestions = std::numeric_limits<int>::max();
}

if (!this->inputHighlighter || nSuggestions == 0)
{
return;
}
Expand All @@ -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 {
Expand Down
Loading