mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-05-30 02:49:12 -04:00
refactor: Improvement code completion auto trigger
This commit is contained in:
@@ -59,6 +59,34 @@ CodeCompletionSettings::CodeCompletionSettings()
|
||||
Tr::tr("Hint-based: Shows a hint when typing, press Tab to request completion\n"
|
||||
"Automatic: Automatically requests completion after typing threshold"));
|
||||
|
||||
completionMode.setLabelText(Tr::tr("Completion mode:"));
|
||||
completionMode.setSettingsKey(Constants::CC_COMPLETION_MODE);
|
||||
completionMode.setDisplayStyle(Utils::SelectionAspect::DisplayStyle::ComboBox);
|
||||
completionMode.addOption("Automatic");
|
||||
completionMode.addOption("Manual");
|
||||
completionMode.setDefaultValue("Automatic");
|
||||
completionMode.setToolTip(
|
||||
Tr::tr("Automatic: requests completion while typing (with smart context gates).\n"
|
||||
"Manual: no auto-triggering; invoke via the 'Request QodeAssist Suggestion' "
|
||||
"shortcut (default Ctrl+Alt+Q, reconfigurable in Preferences > Keyboard)."));
|
||||
|
||||
smartContextTrigger.setSettingsKey(Constants::CC_SMART_CONTEXT_TRIGGER);
|
||||
smartContextTrigger.setLabelText(Tr::tr("Smart context-aware triggering"));
|
||||
smartContextTrigger.setDefaultValue(true);
|
||||
smartContextTrigger.setToolTip(
|
||||
Tr::tr("When enabled, auto-completion is suppressed in places where Qt Creator's built-in "
|
||||
"completion is usually stronger (middle of an identifier, right after '.', '->', "
|
||||
"'::') and is triggered more eagerly after structural characters like '(', ',', "
|
||||
"'{', '=' and on fresh indented lines."));
|
||||
|
||||
respectQtcPopup.setSettingsKey(Constants::CC_RESPECT_QTC_POPUP);
|
||||
respectQtcPopup.setLabelText(Tr::tr("Don't dismiss Qt Creator's completion popup"));
|
||||
respectQtcPopup.setDefaultValue(true);
|
||||
respectQtcPopup.setToolTip(
|
||||
Tr::tr("When enabled, an AI completion arriving while Qt Creator's own completion popup "
|
||||
"is already visible will not force it closed. The LLM suggestion still appears "
|
||||
"inline."));
|
||||
|
||||
startSuggestionTimer.setSettingsKey(Constants::СС_START_SUGGESTION_TIMER);
|
||||
startSuggestionTimer.setLabelText(Tr::tr("with delay(ms)"));
|
||||
startSuggestionTimer.setToolTip(
|
||||
@@ -308,6 +336,8 @@ CodeCompletionSettings::CodeCompletionSettings()
|
||||
|
||||
readSettings();
|
||||
|
||||
migrateCompletionMode();
|
||||
|
||||
readFileParts.setValue(!readFullFile.value());
|
||||
|
||||
setupConnections();
|
||||
@@ -354,30 +384,26 @@ CodeCompletionSettings::CodeCompletionSettings()
|
||||
autoCompletion,
|
||||
multiLineCompletion,
|
||||
Row{modelOutputHandler, Stretch{1}},
|
||||
Row{completionTriggerMode, Stretch{1}},
|
||||
Row{completionMode, Stretch{1}},
|
||||
showProgressWidget,
|
||||
useOpenFilesContext,
|
||||
respectQtcPopup,
|
||||
abortAssistOnRequest,
|
||||
ignoreWhitespaceInCharCount};
|
||||
|
||||
auto autoTriggerSettings = Column{
|
||||
smartContextTrigger,
|
||||
Row{autoCompletionCharThreshold,
|
||||
autoCompletionTypingInterval,
|
||||
startSuggestionTimer,
|
||||
Stretch{1}}};
|
||||
|
||||
auto hintTriggerSettings = Column{
|
||||
Row{hintCharThreshold, hintHideTimeout, Stretch{1}},
|
||||
Row{hintTriggerKey, Stretch{1}}};
|
||||
|
||||
return Column{Row{Stretch{1}, resetToDefaults},
|
||||
Space{8},
|
||||
Group{title(TrConstants::AUTO_COMPLETION_SETTINGS),
|
||||
Column{Group{title(Tr::tr("General Settings")), generalSettings},
|
||||
Space{8},
|
||||
Group{title(Tr::tr("Automatic Trigger Mode")), autoTriggerSettings},
|
||||
Space{8},
|
||||
Group{title(Tr::tr("Hint-based Trigger Mode")), hintTriggerSettings}}},
|
||||
Group{title(Tr::tr("Automatic Trigger Mode")), autoTriggerSettings}}},
|
||||
Space{8},
|
||||
Group{title(Tr::tr("General Parameters")),
|
||||
Column{
|
||||
@@ -460,6 +486,9 @@ void CodeCompletionSettings::resetSettingsToDefaults()
|
||||
resetAspect(useOpenFilesContext);
|
||||
resetAspect(modelOutputHandler);
|
||||
resetAspect(completionTriggerMode);
|
||||
resetAspect(completionMode);
|
||||
resetAspect(smartContextTrigger);
|
||||
resetAspect(respectQtcPopup);
|
||||
resetAspect(hintCharThreshold);
|
||||
resetAspect(hintHideTimeout);
|
||||
resetAspect(hintTriggerKey);
|
||||
@@ -469,6 +498,21 @@ void CodeCompletionSettings::resetSettingsToDefaults()
|
||||
}
|
||||
}
|
||||
|
||||
void CodeCompletionSettings::migrateCompletionMode()
|
||||
{
|
||||
auto *qtcSettings = Core::ICore::settings();
|
||||
if (!qtcSettings || qtcSettings->contains(Constants::CC_COMPLETION_MODE))
|
||||
return;
|
||||
|
||||
const QString oldMode = completionTriggerMode.stringValue();
|
||||
if (oldMode.startsWith("Hint"))
|
||||
completionMode.setStringValue("Manual");
|
||||
else
|
||||
completionMode.setStringValue("Automatic");
|
||||
|
||||
writeSettings();
|
||||
}
|
||||
|
||||
QString CodeCompletionSettings::processMessageToFIM(const QString &prefix, const QString &suffix) const
|
||||
{
|
||||
QString result = userMessageTemplateForCC();
|
||||
|
||||
Reference in New Issue
Block a user