mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-11-22 02:22:44 -05:00
feat: Add settings for ignore space and tab in codecompletion char count
This commit is contained in:
@ -152,14 +152,16 @@ void QodeAssistClient::openDocument(TextEditor::TextDocument *document)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isSpaceOrTab = lastChar[0].isSpace();
|
bool isSpaceOrTab = lastChar[0].isSpace();
|
||||||
|
bool ignoreWhitespace
|
||||||
|
= Settings::codeCompletionSettings().ignoreWhitespaceInCharCount();
|
||||||
|
|
||||||
if (!isSpaceOrTab) {
|
if (!ignoreWhitespace || !isSpaceOrTab) {
|
||||||
m_recentCharCount += charsAdded;
|
m_recentCharCount += charsAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_typingTimer.elapsed()
|
if (m_typingTimer.elapsed()
|
||||||
> Settings::codeCompletionSettings().autoCompletionTypingInterval()) {
|
> Settings::codeCompletionSettings().autoCompletionTypingInterval()) {
|
||||||
m_recentCharCount = isSpaceOrTab ? 0 : charsAdded;
|
m_recentCharCount = (ignoreWhitespace && isSpaceOrTab) ? 0 : charsAdded;
|
||||||
m_typingTimer.restart();
|
m_typingTimer.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -132,6 +132,15 @@ CodeCompletionSettings::CodeCompletionSettings()
|
|||||||
"Space is recommended as least conflicting with context menu.\n"
|
"Space is recommended as least conflicting with context menu.\n"
|
||||||
"(Only for Hint-based trigger mode)"));
|
"(Only for Hint-based trigger mode)"));
|
||||||
|
|
||||||
|
ignoreWhitespaceInCharCount.setSettingsKey(Constants::CC_IGNORE_WHITESPACE_IN_CHAR_COUNT);
|
||||||
|
ignoreWhitespaceInCharCount.setLabelText(
|
||||||
|
Tr::tr("Ignore spaces and tabs in character count"));
|
||||||
|
ignoreWhitespaceInCharCount.setDefaultValue(true);
|
||||||
|
ignoreWhitespaceInCharCount.setToolTip(
|
||||||
|
Tr::tr("When enabled, spaces and tabs are not counted towards the character threshold "
|
||||||
|
"for triggering completions. This helps trigger completions based on actual code "
|
||||||
|
"characters only."));
|
||||||
|
|
||||||
// General Parameters Settings
|
// General Parameters Settings
|
||||||
temperature.setSettingsKey(Constants::CC_TEMPERATURE);
|
temperature.setSettingsKey(Constants::CC_TEMPERATURE);
|
||||||
temperature.setLabelText(Tr::tr("Temperature:"));
|
temperature.setLabelText(Tr::tr("Temperature:"));
|
||||||
@ -364,7 +373,8 @@ CodeCompletionSettings::CodeCompletionSettings()
|
|||||||
|
|
||||||
auto hintTriggerSettings = Column{
|
auto hintTriggerSettings = Column{
|
||||||
Row{hintCharThreshold, hintHideTimeout, Stretch{1}},
|
Row{hintCharThreshold, hintHideTimeout, Stretch{1}},
|
||||||
Row{hintTriggerKey, Stretch{1}}};
|
Row{hintTriggerKey, Stretch{1}},
|
||||||
|
ignoreWhitespaceInCharCount};
|
||||||
|
|
||||||
return Column{Row{Stretch{1}, resetToDefaults},
|
return Column{Row{Stretch{1}, resetToDefaults},
|
||||||
Space{8},
|
Space{8},
|
||||||
@ -461,6 +471,7 @@ void CodeCompletionSettings::resetSettingsToDefaults()
|
|||||||
resetAspect(hintCharThreshold);
|
resetAspect(hintCharThreshold);
|
||||||
resetAspect(hintHideTimeout);
|
resetAspect(hintHideTimeout);
|
||||||
resetAspect(hintTriggerKey);
|
resetAspect(hintTriggerKey);
|
||||||
|
resetAspect(ignoreWhitespaceInCharCount);
|
||||||
resetAspect(abortAssistOnRequest);
|
resetAspect(abortAssistOnRequest);
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,6 +44,7 @@ public:
|
|||||||
Utils::IntegerAspect hintCharThreshold{this};
|
Utils::IntegerAspect hintCharThreshold{this};
|
||||||
Utils::IntegerAspect hintHideTimeout{this};
|
Utils::IntegerAspect hintHideTimeout{this};
|
||||||
Utils::SelectionAspect hintTriggerKey{this};
|
Utils::SelectionAspect hintTriggerKey{this};
|
||||||
|
Utils::BoolAspect ignoreWhitespaceInCharCount{this};
|
||||||
|
|
||||||
Utils::StringListAspect customLanguages{this};
|
Utils::StringListAspect customLanguages{this};
|
||||||
|
|
||||||
|
|||||||
@ -89,6 +89,7 @@ const char CC_HINT_CHAR_THRESHOLD[] = "QodeAssist.ccHintCharThreshold";
|
|||||||
const char CC_HINT_HIDE_TIMEOUT[] = "QodeAssist.ccHintHideTimeout";
|
const char CC_HINT_HIDE_TIMEOUT[] = "QodeAssist.ccHintHideTimeout";
|
||||||
const char CC_HINT_TRIGGER_KEY[] = "QodeAssist.ccHintTriggerKey";
|
const char CC_HINT_TRIGGER_KEY[] = "QodeAssist.ccHintTriggerKey";
|
||||||
const char CC_ABORT_ASSIST_ON_REQUEST[] = "QodeAssist.ccAbortAssistOnRequest";
|
const char CC_ABORT_ASSIST_ON_REQUEST[] = "QodeAssist.ccAbortAssistOnRequest";
|
||||||
|
const char CC_IGNORE_WHITESPACE_IN_CHAR_COUNT[] = "QodeAssist.ccIgnoreWhitespaceInCharCount";
|
||||||
const char MAX_FILE_THRESHOLD[] = "QodeAssist.maxFileThreshold";
|
const char MAX_FILE_THRESHOLD[] = "QodeAssist.maxFileThreshold";
|
||||||
const char CC_MULTILINE_COMPLETION[] = "QodeAssist.ccMultilineCompletion";
|
const char CC_MULTILINE_COMPLETION[] = "QodeAssist.ccMultilineCompletion";
|
||||||
const char CC_MODEL_OUTPUT_HANDLER[] = "QodeAssist.ccModelOutputHandler";
|
const char CC_MODEL_OUTPUT_HANDLER[] = "QodeAssist.ccModelOutputHandler";
|
||||||
|
|||||||
Reference in New Issue
Block a user