Skip to content

Commit

Permalink
Fix Change History wrong display after "Reload from Disk" command
Browse files Browse the repository at this point in the history
The code for fixing is from Change Lines plugin:
https://github.com/vinsworldcom/nppChangedLines/blob/main/PluginDefinition.cpp

Fix #12319, fix #12261, fix #13735, close #13858
  • Loading branch information
donho committed Jul 4, 2023
1 parent 9e24ec5 commit 83d2035
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions PowerEditor/src/Notepad_plus.cpp
Expand Up @@ -8656,3 +8656,16 @@ HBITMAP Notepad_plus::generateSolidColourMenuItemIcon(COLORREF colour)

return hNewBitmap;
}


void Notepad_plus::clearChangesHistory()
{
Sci_Position pos = (Sci_Position)::SendMessage(_pEditView->getHSelf(), SCI_GETCURRENTPOS, 0, 0);
int chFlags = (int)::SendMessage(_pEditView->getHSelf(), SCI_GETCHANGEHISTORY, 0, 0);

SendMessage(_pEditView->getHSelf(), SCI_EMPTYUNDOBUFFER, 0, 0);
SendMessage(_pEditView->getHSelf(), SCI_SETCHANGEHISTORY, SC_CHANGE_HISTORY_DISABLED, 0);

SendMessage(_pEditView->getHSelf(), SCI_SETCHANGEHISTORY, chFlags, 0);
SendMessage(_pEditView->getHSelf(), SCI_GOTOPOS, pos, 0);
}
2 changes: 2 additions & 0 deletions PowerEditor/src/Notepad_plus.h
Expand Up @@ -644,4 +644,6 @@ friend class FileManager;
void updateCommandShortcuts();

HBITMAP generateSolidColourMenuItemIcon(COLORREF colour);

void clearChangesHistory();
};
4 changes: 4 additions & 0 deletions PowerEditor/src/NppIO.cpp
Expand Up @@ -588,6 +588,10 @@ bool Notepad_plus::doReload(BufferID id, bool alert)
// Once reload is complete, activate buffer which will take care of
// many settings such as update status bar, clickable link etc.
activateBuffer(id, currentView(), true);

if (NppParameters::getInstance().getSVP()._isChangeHistoryEnabled4NextSession)
clearChangesHistory();

return res;
}

Expand Down

0 comments on commit 83d2035

Please sign in to comment.