Fix Change History wrong display after "Reload from Disk" command

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
pull/13869/head
Don Ho 2023-07-03 21:51:35 +02:00
parent 9e24ec55db
commit 83d203561d
3 changed files with 19 additions and 0 deletions

View File

@ -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);
}

View File

@ -644,4 +644,6 @@ private:
void updateCommandShortcuts();
HBITMAP generateSolidColourMenuItemIcon(COLORREF colour);
void clearChangesHistory();
};

View File

@ -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;
}