Optimize setting image call in auto-completion

In PR #11088 the calling scinitilla is not optimized:
SCI_REGISTERIMAGE & SCI_AUTOCSETTYPESEPARATOR need to be called only once.
This commit is contained in:
Don Ho 2022-02-07 20:12:45 +01:00
parent c394a890aa
commit 6c345e907b
2 changed files with 13 additions and 7 deletions

View File

@ -117,9 +117,13 @@ bool AutoCompletion::showApiComplete()
if (len >= _keyWordMaxLen)
return false;
if (!_isFxImageRegistered)
{
_pEditView->execute(SCI_AUTOCSETTYPESEPARATOR, WPARAM('?'));
_pEditView->execute(SCI_REGISTERIMAGE, FUNC_IMG_ID, LPARAM(xpmfn));
_isFxImageRegistered = true;
}
_pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM(' '));
_pEditView->execute(SCI_AUTOCSETTYPESEPARATOR, WPARAM('?'));
_pEditView->execute(SCI_REGISTERIMAGE, FUNC_IMG_ID, LPARAM(xpmfn));
_pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase);
_pEditView->showAutoComletion(curPos - startPos, _keyWords.c_str());
@ -202,10 +206,13 @@ bool AutoCompletion::showApiAndWordComplete()
}
// Make Scintilla show the autocompletion menu
if (!_isFxImageRegistered)
{
_pEditView->execute(SCI_AUTOCSETTYPESEPARATOR, WPARAM('?'));
_pEditView->execute(SCI_REGISTERIMAGE, FUNC_IMG_ID, LPARAM(xpmfn));
_isFxImageRegistered = true;
}
_pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM(' '));
_pEditView->execute(SCI_AUTOCSETTYPESEPARATOR, WPARAM('?'));
_pEditView->execute(SCI_REGISTERIMAGE, FUNC_IMG_ID, LPARAM(xpmfn));
_pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase);
_pEditView->showAutoComletion(curPos - startPos, words.c_str());
return true;
@ -464,8 +471,6 @@ bool AutoCompletion::showWordComplete(bool autoInsert)
// Make Scintilla show the autocompletion menu
_pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM(' '));
_pEditView->execute(SCI_AUTOCSETTYPESEPARATOR, WPARAM('?'));
_pEditView->execute(SCI_REGISTERIMAGE, FUNC_IMG_ID, LPARAM(xpmfn));
_pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase);
_pEditView->showAutoComletion(curPos - startPos, words.c_str());
return true;

View File

@ -79,6 +79,7 @@ private:
LangType _curLang = L_TEXT;
TiXmlDocument *_pXmlFile = nullptr;
TiXmlElement *_pXmlKeyword = nullptr;
bool _isFxImageRegistered = false;
InsertedMatchedChars _insertedMatchedChars;