diff --git a/QodeAssistClient.cpp b/QodeAssistClient.cpp index a7bc8c8..a6b4aae 100644 --- a/QodeAssistClient.cpp +++ b/QodeAssistClient.cpp @@ -336,8 +336,12 @@ void QodeAssistClient::requestQuickRefactor( void QodeAssistClient::scheduleRequest(TextEditor::TextEditorWidget *editor) { - if (m_runningRequests.contains(editor)) - return; + if (m_runningRequests.contains(editor)) { + if (Settings::codeCompletionSettings().cancelOnInput()) + cancelRunningRequest(editor); + else + return; + } auto it = m_scheduledRequests.find(editor); if (it == m_scheduledRequests.end()) { diff --git a/settings/CodeCompletionSettings.cpp b/settings/CodeCompletionSettings.cpp index 392df35..cf8a8ca 100644 --- a/settings/CodeCompletionSettings.cpp +++ b/settings/CodeCompletionSettings.cpp @@ -87,6 +87,17 @@ CodeCompletionSettings::CodeCompletionSettings() "is already visible will not force it closed. The LLM suggestion still appears " "inline.")); + cancelOnInput.setSettingsKey(Constants::CC_CANCEL_ON_INPUT); + cancelOnInput.setLabelText(Tr::tr("Cancel in-flight request on new input")); + cancelOnInput.setDefaultValue(false); + cancelOnInput.setToolTip( + Tr::tr("When enabled, every new keystroke cancels any completion request already in " + "flight and restarts the debounce timer. Useful for slow local models where an " + "outdated answer is rarely worth waiting for.\n" + "When disabled (default), the in-flight request is kept; when the answer arrives, " + "the plugin compares it with characters typed in the meantime and either trims " + "the matching prefix or drops the answer.")); + startSuggestionTimer.setSettingsKey(Constants::СС_START_SUGGESTION_TIMER); startSuggestionTimer.setLabelText(Tr::tr("with delay(ms)")); startSuggestionTimer.setToolTip( @@ -388,6 +399,7 @@ CodeCompletionSettings::CodeCompletionSettings() showProgressWidget, useOpenFilesContext, respectQtcPopup, + cancelOnInput, abortAssistOnRequest, ignoreWhitespaceInCharCount}; @@ -489,6 +501,7 @@ void CodeCompletionSettings::resetSettingsToDefaults() resetAspect(completionMode); resetAspect(smartContextTrigger); resetAspect(respectQtcPopup); + resetAspect(cancelOnInput); resetAspect(hintCharThreshold); resetAspect(hintHideTimeout); resetAspect(hintTriggerKey); diff --git a/settings/CodeCompletionSettings.hpp b/settings/CodeCompletionSettings.hpp index c12841d..f588238 100644 --- a/settings/CodeCompletionSettings.hpp +++ b/settings/CodeCompletionSettings.hpp @@ -24,6 +24,7 @@ public: Utils::SelectionAspect completionMode{this}; Utils::BoolAspect smartContextTrigger{this}; Utils::BoolAspect respectQtcPopup{this}; + Utils::BoolAspect cancelOnInput{this}; Utils::IntegerAspect startSuggestionTimer{this}; Utils::IntegerAspect autoCompletionCharThreshold{this}; diff --git a/settings/GeneralSettings.cpp b/settings/GeneralSettings.cpp index 10d1c86..bfcddcd 100644 --- a/settings/GeneralSettings.cpp +++ b/settings/GeneralSettings.cpp @@ -178,7 +178,7 @@ GeneralSettings::GeneralSettings() caProvider.setReadOnly(true); caSelectProvider.m_buttonText = TrConstants::SELECT; - initStringAspect(caModel, Constants::CA_MODEL, TrConstants::MODEL, "qwen2.5-coder:7b"); + initStringAspect(caModel, Constants::CA_MODEL, TrConstants::MODEL, "qwen3.5:9b"); caModel.setHistoryCompleter(Constants::CA_MODEL_HISTORY); caSelectModel.m_buttonText = TrConstants::SELECT; @@ -215,7 +215,7 @@ GeneralSettings::GeneralSettings() qrProvider.setReadOnly(true); qrSelectProvider.m_buttonText = TrConstants::SELECT; - initStringAspect(qrModel, Constants::QR_MODEL, TrConstants::MODEL, "qwen2.5-coder:7b"); + initStringAspect(qrModel, Constants::QR_MODEL, TrConstants::MODEL, "qwen3.5:9b"); qrModel.setHistoryCompleter(Constants::QR_MODEL_HISTORY); qrSelectModel.m_buttonText = TrConstants::SELECT; diff --git a/settings/SettingsConstants.hpp b/settings/SettingsConstants.hpp index c7ad6fb..d6508c2 100644 --- a/settings/SettingsConstants.hpp +++ b/settings/SettingsConstants.hpp @@ -68,6 +68,7 @@ const char CC_COMPLETION_TRIGGER_MODE[] = "QodeAssist.ccCompletionTriggerMode"; const char CC_COMPLETION_MODE[] = "QodeAssist.ccCompletionMode"; const char CC_SMART_CONTEXT_TRIGGER[] = "QodeAssist.ccSmartContextTrigger"; const char CC_RESPECT_QTC_POPUP[] = "QodeAssist.ccRespectQtcPopup"; +const char CC_CANCEL_ON_INPUT[] = "QodeAssist.ccCancelOnInput"; const char CC_HINT_CHAR_THRESHOLD[] = "QodeAssist.ccHintCharThreshold"; const char CC_HINT_HIDE_TIMEOUT[] = "QodeAssist.ccHintHideTimeout"; const char CC_HINT_TRIGGER_KEY[] = "QodeAssist.ccHintTriggerKey";