diff --git a/NEWS.md b/NEWS.md
index cd731b6a..fe6f265c 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -4,6 +4,7 @@ Red Panda C++ Version 0.13.2
- enhancement: can add non-code file in templates
- enhancement: if there's no selection when copy/cut, select currect line by default
- enhancement: support ligatures in fonts like fira code ( disabled by default, can be turned on in options dialog's editor font page)
+ - enhancement: add "minimum id length required to show code completion" to the options dialog's editor code completion page
Red Panda C++ Version 0.13.1
- enhancement: suppoort localization info in project templates
diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts
index a8ce594d..76d97719 100644
--- a/RedPandaIDE/RedPandaIDE_zh_CN.ts
+++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts
@@ -1205,10 +1205,10 @@ Are you really want to continue?
-
-
-
-
+
+
+
+
错误
@@ -1222,65 +1222,65 @@ Are you really want to continue?
另存为
-
+
要复制的内容超过了行数限制!
-
+
要复制的内容超过了字符数限制!
-
+
要剪切的内容超过了行数限制!
-
+
要剪切的内容超过了字符数限制!
-
+
打印文档
-
-
-
+
+
+
Ctrl+单击以获取更多信息
-
-
+
+
未找到符号'%1'!
-
+
找不到astyle程序
-
+
找不到astyle程序"%1".
-
+
断点条件
-
+
输入当前断点的生效条件:
-
+
只读
@@ -1436,72 +1436,77 @@ Are you really want to continue?
启用代码补全
-
+
+
+ 显示代码补全所需的标识符最短长度
+
+
+
清除不活动编辑器中的符号表(大幅减少内存占用)
-
+
输入时显示补全提示
-
+
引擎选项
-
+
扫描本地头文件
-
+
扫描系统头文件
-
+
提示C/C++关键字
-
+
提示用户自定义代码段
-
+
补全函数时自动添加()
-
+
查找提示时忽略大小写
-
+
优先提示局部作用域中的符号
-
+
优先提示经常使用的符号
-
+
清除使用数据
-
+
补全提示窗口宽度:
-
+
补全提示窗口高度:
@@ -7289,8 +7294,8 @@ Are you really want to continue?
SynEdit
-
+
高亮处理进入了死循环
diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp
index 38a9163b..80c54e7e 100644
--- a/RedPandaIDE/editor.cpp
+++ b/RedPandaIDE/editor.cpp
@@ -701,54 +701,52 @@ void Editor::keyPressEvent(QKeyEvent *event)
mLastIdCharPressed++;
if (pSettings->codeCompletion().enabled()
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
- if (mLastIdCharPressed==1) {
- if (mParser && mParser->isIncludeLine(lineText())) {
- // is a #include line
- setSelText(ch);
- showHeaderCompletion(false);
- handled=true;
- return;
- } else {
- QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY());
- if (!lastWord.isEmpty()) {
- if (CppTypeKeywords.contains(lastWord)) {
- if (lastWord == "long" ||
- lastWord == "short" ||
- lastWord == "signed" ||
- lastWord == "unsigned"
- ) {
- setSelText(ch);
- showCompletion(lastWord,false);
- handled=true;
- return;
- }
- //last word is a type keyword, this is a var or param define, and dont show suggestion
- // if devEditor.UseTabnine then
- // ShowTabnineCompletion;
- return;
- }
- PStatement statement = mParser->findStatementOf(
- mFilename,
- lastWord,
- caretY());
- StatementKind kind = mParser->getKindOfStatement(statement);
- if (kind == StatementKind::skClass
- || kind == StatementKind::skEnumClassType
- || kind == StatementKind::skEnumType
- || kind == StatementKind::skTypedef) {
- //last word is a typedef/class/struct, this is a var or param define, and dont show suggestion
- // if devEditor.UseTabnine then
- // ShowTabnineCompletion;
+ if (mParser && mParser->isIncludeLine(lineText())
+ && mLastIdCharPressed==pSettings->codeCompletion().minCharRequired()) {
+ // is a #include line
+ setSelText(ch);
+ showHeaderCompletion(false);
+ handled=true;
+ return;
+ } else if (mLastIdCharPressed==pSettings->codeCompletion().minCharRequired()){
+ QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY());
+ if (!lastWord.isEmpty()) {
+ if (CppTypeKeywords.contains(lastWord)) {
+ if (lastWord == "long" ||
+ lastWord == "short" ||
+ lastWord == "signed" ||
+ lastWord == "unsigned"
+ ) {
+ setSelText(ch);
+ showCompletion(lastWord,false);
+ handled=true;
return;
}
+ //last word is a type keyword, this is a var or param define, and dont show suggestion
+ // if devEditor.UseTabnine then
+ // ShowTabnineCompletion;
+ return;
+ }
+ PStatement statement = mParser->findStatementOf(
+ mFilename,
+ lastWord,
+ caretY());
+ StatementKind kind = mParser->getKindOfStatement(statement);
+ if (kind == StatementKind::skClass
+ || kind == StatementKind::skEnumClassType
+ || kind == StatementKind::skEnumType
+ || kind == StatementKind::skTypedef) {
+ //last word is a typedef/class/struct, this is a var or param define, and dont show suggestion
+ // if devEditor.UseTabnine then
+ // ShowTabnineCompletion;
+ return;
}
- setSelText(ch);
- showCompletion("",false);
- handled=true;
- return;
}
+ setSelText(ch);
+ showCompletion("",false);
+ handled=true;
+ return;
}
-
}
} else {
//preprocessor ?
@@ -1151,7 +1149,7 @@ void Editor::inputMethodEvent(QInputMethodEvent *event)
mLastIdCharPressed+=s.length();
if (pSettings->codeCompletion().enabled()
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
- if (mLastIdCharPressed>=1) {
+ if (mLastIdCharPressed>=pSettings->codeCompletion().minCharRequired()) {
QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY());
if (!lastWord.isEmpty()) {
if (CppTypeKeywords.contains(lastWord)) {
diff --git a/RedPandaIDE/qsynedit/TextPainter.cpp b/RedPandaIDE/qsynedit/TextPainter.cpp
index 77976bce..3a40c7dd 100644
--- a/RedPandaIDE/qsynedit/TextPainter.cpp
+++ b/RedPandaIDE/qsynedit/TextPainter.cpp
@@ -400,6 +400,7 @@ void SynEditTextPainter::PaintToken(const QString &Token, int TokenCols, int Col
startPaint = false;
for (int i=0;imTabWidth - ((ColumnsBefore+tokenColLen) % edit->mTabWidth);
} else {
diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp
index 733d80f8..4acfd35a 100644
--- a/RedPandaIDE/settings.cpp
+++ b/RedPandaIDE/settings.cpp
@@ -3479,6 +3479,16 @@ void Settings::CodeCompletion::setClearWhenEditorHidden(bool newClearWhenEditorH
mClearWhenEditorHidden = newClearWhenEditorHidden;
}
+int Settings::CodeCompletion::minCharRequired() const
+{
+ return mMinCharRequired;
+}
+
+void Settings::CodeCompletion::setMinCharRequired(int newMinCharRequired)
+{
+ mMinCharRequired = newMinCharRequired;
+}
+
bool Settings::CodeCompletion::appendFunc() const
{
return mAppendFunc;
@@ -3604,6 +3614,7 @@ void Settings::CodeCompletion::doSave()
saveValue("append_func",mAppendFunc);
saveValue("show_code_ins",mShowCodeIns);
saveValue("clear_when_editor_hidden",mClearWhenEditorHidden);
+ saveValue("min_char_required",mMinCharRequired);
}
@@ -3622,6 +3633,7 @@ void Settings::CodeCompletion::doLoad()
mIgnoreCase = boolValue("ignore_case",true);
mAppendFunc = boolValue("append_func",true);
mShowCodeIns = boolValue("show_code_ins",true);
+ mMinCharRequired = intValue("min_char_required",1);
bool doClear = true;
diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h
index 9ec48f48..9f47e14a 100644
--- a/RedPandaIDE/settings.h
+++ b/RedPandaIDE/settings.h
@@ -576,6 +576,9 @@ public:
bool clearWhenEditorHidden() const;
void setClearWhenEditorHidden(bool newClearWhenEditorHidden);
+ int minCharRequired() const;
+ void setMinCharRequired(int newMinCharRequired);
+
private:
int mWidth;
int mHeight;
@@ -590,6 +593,7 @@ public:
bool mAppendFunc;
bool mShowCodeIns;
bool mClearWhenEditorHidden;
+ int mMinCharRequired;
// _Base interface
protected:
diff --git a/RedPandaIDE/settingsdialog/editorcodecompletionwidget.cpp b/RedPandaIDE/settingsdialog/editorcodecompletionwidget.cpp
index 5b5248e5..eb05e37e 100644
--- a/RedPandaIDE/settingsdialog/editorcodecompletionwidget.cpp
+++ b/RedPandaIDE/settingsdialog/editorcodecompletionwidget.cpp
@@ -50,6 +50,8 @@ void EditorCodeCompletionWidget::doLoad()
ui->chkIgnoreCases->setChecked(pSettings->codeCompletion().ignoreCase());
ui->chkAppendFunc->setChecked(pSettings->codeCompletion().appendFunc());
ui->chkShowCodeIns->setChecked(pSettings->codeCompletion().showCodeIns());
+
+ ui->spinMinCharRequired->setValue(pSettings->codeCompletion().minCharRequired());
}
void EditorCodeCompletionWidget::doSave()
@@ -70,6 +72,8 @@ void EditorCodeCompletionWidget::doSave()
pSettings->codeCompletion().setIgnoreCase(ui->chkIgnoreCases->isChecked());
pSettings->codeCompletion().setAppendFunc(ui->chkAppendFunc->isChecked());
pSettings->codeCompletion().setShowCodeIns(ui->chkShowCodeIns->isChecked());
+ pSettings->codeCompletion().setMinCharRequired(ui->spinMinCharRequired->value());
+
pSettings->codeCompletion().save();
}
diff --git a/RedPandaIDE/settingsdialog/editorcodecompletionwidget.ui b/RedPandaIDE/settingsdialog/editorcodecompletionwidget.ui
index 5309b6a8..95e02252 100644
--- a/RedPandaIDE/settingsdialog/editorcodecompletionwidget.ui
+++ b/RedPandaIDE/settingsdialog/editorcodecompletionwidget.ui
@@ -26,6 +26,54 @@
true
+ -
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ Minimum id length to show completion
+
+
+
+ -
+
+
+ 1
+
+
+ 20
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
-