From 4fc06e2bc196da8f1d2ee056e422d80d3744c2c2 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 29 Aug 2015 21:49:49 +0200 Subject: [PATCH] Fix plugin shortcut configuration lost problem by using option -noPlugin. (closes #589) Solution: save shortcut.xml only if shortcuts have been modified. --- PowerEditor/bin/change.log | 16 ++--- PowerEditor/src/Parameters.cpp | 4 +- PowerEditor/src/Parameters.h | 5 +- .../src/WinControls/Grid/ShortcutMapper.cpp | 62 ++++++++++++++----- 4 files changed, 57 insertions(+), 30 deletions(-) diff --git a/PowerEditor/bin/change.log b/PowerEditor/bin/change.log index b72a7e0a9..a3ae22093 100644 --- a/PowerEditor/bin/change.log +++ b/PowerEditor/bin/change.log @@ -1,15 +1,9 @@ -Notepad++ v6.8.2 bug-fixes: +Notepad++ v6.8.3 bug-fixes: + +1. Fix the crash by using wild card (*) to open files on command line. +2. Fix the problem of display refresh missing on exit. +3. Fix plugin shortcut configuration lost problem by using option -noPlugin. -1. Remove Source Code Pro font du to the different issues. -2. Add back "Notepad++ Community (Forum)" menu item. -3. Fix a visual glitch on starup and on exit. -4. Fix "Open in/Move to new instance" issue (to memorize the language and the position). -5. Fix Preferences dialog loses focus issue while enabling document list panel. -6. Fix the narrow columns problem in Ascii Insert Panel under a high DPI. -7. Fix the list items' squeezed height problem in function list panel and project panel under a high DPI. -8. Fix panel caption squeezed display under a high DPI. -9. Fixed buffer overrun when opening a recent file. -10. Make toolbar refresh properly while switching over small/big icons. Included plugins: diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 92ea9dd4d..b212cfaf6 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2934,7 +2934,9 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName) void NppParameters::writeShortcuts() { - if (!_pXmlShortcutDoc) + if (not _isAnyShortcutModified) return; + + if (not _pXmlShortcutDoc) { //do the treatment _pXmlShortcutDoc = new TiXmlDocument(_shortcutsPath); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 852f27f21..6aedb10e5 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -1626,7 +1626,10 @@ private: WNDPROC _enableThemeDialogTextureFuncAddr; bool _isLocal; - +public: + void setShortcutDirty() { _isAnyShortcutModified = true; }; +private: + bool _isAnyShortcutModified = false; std::vector _shortcuts; //main menu shortuts. Static size std::vector _customizedShortcuts; //altered main menu shortcuts. Indices static. Needed when saving alterations std::vector _macros; //macro shortcuts, dynamic size, defined on loading macros and adding/deleting them diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp index e446fee9f..f32f7c1ac 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp @@ -230,59 +230,78 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM NppParameters *nppParam = NppParameters::getInstance(); int row = _babygrid.getSelectedRow(); - switch(_currentState) { - case STATE_MENU: { + switch(_currentState) + { + case STATE_MENU: + { //Get CommandShortcut corresponding to row vector & shortcuts = nppParam->getUserShortcuts(); CommandShortcut csc = shortcuts[row - 1], prevcsc = shortcuts[row - 1]; csc.init(_hInst, _hSelf); - if (csc.doDialog() != -1 && prevcsc != csc) { //shortcut was altered + if (csc.doDialog() != -1 && prevcsc != csc) + { + //shortcut was altered nppParam->addUserModifiedIndex(row-1); shortcuts[row - 1] = csc; _babygrid.setText(row, 2, csc.toString().c_str()); //Notify current Accelerator class to update everything nppParam->getAccelerator()->updateShortcuts(); - + nppParam->setShortcutDirty(); } - break; } - case STATE_MACRO: { + break; + } + + case STATE_MACRO: + { //Get MacroShortcut corresponding to row vector & shortcuts = nppParam->getMacroList(); MacroShortcut msc = shortcuts[row - 1], prevmsc = shortcuts[row - 1]; msc.init(_hInst, _hSelf); - if (msc.doDialog() != -1 && prevmsc != msc) { //shortcut was altered + if (msc.doDialog() != -1 && prevmsc != msc) + { + //shortcut was altered shortcuts[row - 1] = msc; _babygrid.setText(row, 1, msc.getName()); _babygrid.setText(row, 2, msc.toString().c_str()); //Notify current Accelerator class to update everything nppParam->getAccelerator()->updateShortcuts(); - + nppParam->setShortcutDirty(); } - break; } - case STATE_USER: { + break; + } + + case STATE_USER: + { //Get UserCommand corresponding to row vector & shortcuts = nppParam->getUserCommandList(); UserCommand ucmd = shortcuts[row - 1], prevucmd = shortcuts[row - 1]; ucmd.init(_hInst, _hSelf); prevucmd = ucmd; - if (ucmd.doDialog() != -1 && prevucmd != ucmd) { //shortcut was altered + if (ucmd.doDialog() != -1 && prevucmd != ucmd) + { + //shortcut was altered shortcuts[row - 1] = ucmd; _babygrid.setText(row, 1, ucmd.getName()); _babygrid.setText(row, 2, ucmd.toString().c_str()); //Notify current Accelerator class to update everything nppParam->getAccelerator()->updateShortcuts(); - + nppParam->setShortcutDirty(); } - break; } - case STATE_PLUGIN: { + break; + } + + case STATE_PLUGIN: + { //Get PluginCmdShortcut corresponding to row vector & shortcuts = nppParam->getPluginCommandList(); PluginCmdShortcut pcsc = shortcuts[row - 1], prevpcsc = shortcuts[row - 1]; pcsc.init(_hInst, _hSelf); prevpcsc = pcsc; - if (pcsc.doDialog() != -1 && prevpcsc != pcsc) { //shortcut was altered + if (pcsc.doDialog() != -1 && prevpcsc != pcsc) + { + //shortcut was altered nppParam->addPluginModifiedIndex(row-1); shortcuts[row - 1] = pcsc; _babygrid.setText(row, 2, pcsc.toString().c_str()); @@ -297,9 +316,13 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM shortcut._key = pcsc.getKeyCombo()._key; ::SendMessage(_hParent, NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED, cmdID, (LPARAM)&shortcut); + nppParam->setShortcutDirty(); } - break; } - case STATE_SCINTILLA: { + break; + } + + case STATE_SCINTILLA: + { //Get ScintillaKeyMap corresponding to row vector & shortcuts = nppParam->getScintillaKeyList(); ScintillaKeyMap skm = shortcuts[row - 1], prevskm = shortcuts[row-1]; @@ -313,12 +336,14 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM //Notify current Accelerator class to update key nppParam->getScintillaAccelerator()->updateKeys(); + nppParam->setShortcutDirty(); } break; } } return TRUE; } + case IDM_BABYGRID_DELETE : { NppParameters *nppParam = NppParameters::getInstance(); @@ -341,6 +366,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM { return FALSE; //this is bad } + case STATE_MACRO: { vector & theMacros = nppParam->getMacroList(); @@ -362,6 +388,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM } break; } + case STATE_USER: { vector & theUserCmds = nppParam->getUserCommandList(); @@ -387,6 +414,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM // updateShortcuts() will update all menu item - the menu items will be shifted nppParam->getAccelerator()->updateShortcuts(); + nppParam->setShortcutDirty(); // All menu items are shifted up. So we delete the last item ::RemoveMenu(hMenu, posBase + nbElem, MF_BYPOSITION);