Skip to content

Commit

Permalink
Fix plugin shortcut configuration lost problem by using option -noPlu…
Browse files Browse the repository at this point in the history
…gin. (closes notepad-plus-plus#589)

Solution: save shortcut.xml only if shortcuts have been modified.
  • Loading branch information
donho committed Aug 29, 2015
1 parent d7ca1ea commit 4fc06e2
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 30 deletions.
16 changes: 5 additions & 11 deletions PowerEditor/bin/change.log
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 3 additions & 1 deletion PowerEditor/src/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion PowerEditor/src/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,10 @@ class NppParameters final
WNDPROC _enableThemeDialogTextureFuncAddr;
bool _isLocal;


public:
void setShortcutDirty() { _isAnyShortcutModified = true; };
private:
bool _isAnyShortcutModified = false;
std::vector<CommandShortcut> _shortcuts; //main menu shortuts. Static size
std::vector<int> _customizedShortcuts; //altered main menu shortcuts. Indices static. Needed when saving alterations
std::vector<MacroShortcut> _macros; //macro shortcuts, dynamic size, defined on loading macros and adding/deleting them
Expand Down
62 changes: 45 additions & 17 deletions PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CommandShortcut> & 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<MacroShortcut> & 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<UserCommand> & 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<PluginCmdShortcut> & 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());
Expand All @@ -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<ScintillaKeyMap> & shortcuts = nppParam->getScintillaKeyList();
ScintillaKeyMap skm = shortcuts[row - 1], prevskm = shortcuts[row-1];
Expand All @@ -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();
Expand All @@ -341,6 +366,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{
return FALSE; //this is bad
}

case STATE_MACRO:
{
vector<MacroShortcut> & theMacros = nppParam->getMacroList();
Expand All @@ -362,6 +388,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
}
break;
}

case STATE_USER:
{
vector<UserCommand> & theUserCmds = nppParam->getUserCommandList();
Expand All @@ -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);
Expand Down

0 comments on commit 4fc06e2

Please sign in to comment.