diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 75ee85d32..7b685de81 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -1844,7 +1844,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) charAdded(static_cast(notification->ch)); const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI(); if (nppGUI._autocStatus == nppGUI.autoc_word) - autoCompFromCurrentFile(); + autoCompFromCurrentFile(false); else if (nppGUI._autocStatus == nppGUI.autoc_func) showAutoComp(); @@ -4494,7 +4494,7 @@ static bool isInList(string word, const vector & wordArray) return false; }; -void Notepad_plus::autoCompFromCurrentFile() +void Notepad_plus::autoCompFromCurrentFile(bool autoInsert) { int curPos = int(_pEditView->execute(SCI_GETCURRENTPOS)); int startPos = int(_pEditView->execute(SCI_WORDSTARTPOSITION, curPos, true)); @@ -4542,7 +4542,7 @@ void Notepad_plus::autoCompFromCurrentFile() } if (wordArray.size() == 0) return; - if (wordArray.size() == 1) + if (wordArray.size() == 1 && autoInsert) { _pEditView->execute(SCI_SETTARGETSTART, startPos); _pEditView->execute(SCI_SETTARGETEND, curPos); diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 4203b4390..59af3ac79 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -827,7 +827,7 @@ private: void updateStatusBar(); void showAutoComp(); - void autoCompFromCurrentFile(); + void autoCompFromCurrentFile(bool autoInsert = true); void getApiFileName(LangType langType, std::string &fn); void changeStyleCtrlsLang(HWND hDlg, int *idArray, const char **translatedText); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 84ff45aa1..c0e762b0b 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2045,6 +2045,12 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) _nppGUI._globalOverride.enableUnderLine = true; } } + else if (!strcmp(nm, "auto-completion")) + { + int i; + if (element->Attribute("autoCAction", &i)) + _nppGUI._autocStatus = (NppGUI::AutocStatus)i; + } } } @@ -2317,6 +2323,7 @@ void NppParameters::writeGUIParams() bool saveOpenFileInSameDirExist = false; bool URLExist = false; bool globalOverrideExist = false; + bool autocExist = false; TiXmlNode *dockingParamNode = NULL; @@ -2499,6 +2506,12 @@ void NppParameters::writeGUIParams() pStr = _nppGUI._globalOverride.enableUnderLine?"yes":"no"; element->SetAttribute("underline", pStr); } + + if (!strcmp(nm, "auto-completion")) + { + autocExist = true; + element->SetAttribute("autoCAction", _nppGUI._autocStatus); + } } if (!autoDetectionExist) @@ -2593,6 +2606,13 @@ void NppParameters::writeGUIParams() GUIConfigElement->SetAttribute("italic", _nppGUI._globalOverride.enableItalic?"yes":"no"); GUIConfigElement->SetAttribute("underline", _nppGUI._globalOverride.enableUnderLine?"yes":"no"); } + + if (!autocExist) + { + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); + GUIConfigElement->SetAttribute("name", "auto-completion"); + GUIConfigElement->SetAttribute("autoCAction", _nppGUI._autocStatus); + } if (!saveOpenFileInSameDirExist) { diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 4305ec703..cc13eb032 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -490,7 +490,7 @@ struct NppGUI _splitterPos(POS_HORIZOTAL), _userDefineDlgStatus(UDD_DOCKED), _tabSize(8),\ _tabReplacedBySpace(false), _fileAutoDetection(cdEnabled), _checkHistoryFiles(true),\ _isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false),\ - _doTaskList(true), _maitainIndent(true), _saveOpenKeepInSameDir(false), _styleMRU(true), _styleURL(0) { + _doTaskList(true), _maitainIndent(true), _saveOpenKeepInSameDir(false), _styleMRU(true), _styleURL(0), _autocStatus(autoc_none) { _appPos.left = 0; _appPos.top = 0; _appPos.right = 700;