mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-10-17 05:39:21 +02:00
Fix Monitoring in one view affects selections and position in second view
Fix #17046, close #17056
This commit is contained in:
parent
f424ec1590
commit
d3bb31b0ec
@ -9030,19 +9030,33 @@ HBITMAP Notepad_plus::generateSolidColourMenuItemIcon(COLORREF colour)
|
||||
return hNewBitmap;
|
||||
}
|
||||
|
||||
|
||||
void Notepad_plus::clearChangesHistory()
|
||||
void Notepad_plus::clearChangesHistory(int iView)
|
||||
{
|
||||
Sci_Position pos = (Sci_Position)::SendMessage(_pEditView->getHSelf(), SCI_GETCURRENTPOS, 0, 0);
|
||||
int chFlags = (int)::SendMessage(_pEditView->getHSelf(), SCI_GETCHANGEHISTORY, 0, 0);
|
||||
// use current view by default
|
||||
ScintillaEditView* pViewToChange = _pEditView;
|
||||
ScintillaEditView* pAnotherView = _pNonEditView;
|
||||
|
||||
_pEditView->execute(SCI_EMPTYUNDOBUFFER);
|
||||
_pEditView->execute(SCI_SETCHANGEHISTORY, SC_CHANGE_HISTORY_DISABLED);
|
||||
_pEditView->execute(SCI_SETCHANGEHISTORY, chFlags);
|
||||
_pEditView->execute(SCI_GOTOPOS, pos);
|
||||
if (iView == MAIN_VIEW)
|
||||
{
|
||||
pViewToChange = &_mainEditView;
|
||||
pAnotherView = &_subEditView;
|
||||
}
|
||||
else if (iView == SUB_VIEW)
|
||||
{
|
||||
pViewToChange = &_subEditView;
|
||||
pAnotherView = &_mainEditView;
|
||||
}
|
||||
|
||||
Sci_Position pos = static_cast<Sci_Position>(::SendMessage(pViewToChange->getHSelf(), SCI_GETCURRENTPOS, 0, 0));
|
||||
int chFlags = static_cast<int>(::SendMessage(pViewToChange->getHSelf(), SCI_GETCHANGEHISTORY, 0, 0));
|
||||
|
||||
pViewToChange->execute(SCI_EMPTYUNDOBUFFER);
|
||||
pViewToChange->execute(SCI_SETCHANGEHISTORY, SC_CHANGE_HISTORY_DISABLED);
|
||||
pViewToChange->execute(SCI_SETCHANGEHISTORY, chFlags);
|
||||
pViewToChange->execute(SCI_GOTOPOS, pos);
|
||||
|
||||
checkUndoState();
|
||||
_pNonEditView->redraw(); // Prevent cloned document visual glichy on another view
|
||||
pAnotherView->redraw(); // Prevent cloned document visual glitch on another view
|
||||
}
|
||||
|
||||
// Based on https://github.com/notepad-plus-plus/notepad-plus-plus/issues/12248#issuecomment-1258561261.
|
||||
|
@ -662,7 +662,7 @@ private:
|
||||
|
||||
HBITMAP generateSolidColourMenuItemIcon(COLORREF colour);
|
||||
|
||||
void clearChangesHistory();
|
||||
void clearChangesHistory(int iView);
|
||||
void changedHistoryGoTo(int idGoTo);
|
||||
|
||||
HMENU createMenuFromMenu(HMENU hSourceMenu, const std::vector<int>& commandIds);
|
||||
|
@ -1782,9 +1782,9 @@ void Notepad_plus::command(int id)
|
||||
changedHistoryGoTo(id);
|
||||
break;
|
||||
|
||||
case IDM_SEARCH_CLEAR_CHANGE_HISTORY:
|
||||
clearChangesHistory();
|
||||
break;
|
||||
case IDM_SEARCH_CLEAR_CHANGE_HISTORY:
|
||||
clearChangesHistory(currentView());
|
||||
break;
|
||||
|
||||
case IDM_LANG_USER_DLG :
|
||||
{
|
||||
|
@ -609,15 +609,21 @@ bool Notepad_plus::doReload(BufferID id, bool alert)
|
||||
_subEditView.restoreCurrentPosPreStep();
|
||||
}
|
||||
|
||||
auto svp = NppParameters::getInstance().getSVP();
|
||||
|
||||
// Once reload is complete, activate buffer which will take care of
|
||||
// many settings such as update status bar, clickable link etc.
|
||||
if ( ((currentView() == MAIN_VIEW) && mainVisible) || ((currentView() == SUB_VIEW) && subVisible))
|
||||
{
|
||||
activateBuffer(id, currentView(), true);
|
||||
|
||||
if (svp._isChangeHistoryMarginEnabled || svp._isChangeHistoryIndicatorEnabled)
|
||||
clearChangesHistory(currentView());
|
||||
}
|
||||
else
|
||||
{
|
||||
// handle also the less usual case when the reloaded buffer is not in the current active view
|
||||
|
||||
int originalActiveView = currentView();
|
||||
BufferID originalActiveBufferID = nullptr;
|
||||
if (mainVisible)
|
||||
@ -631,11 +637,10 @@ bool Notepad_plus::doReload(BufferID id, bool alert)
|
||||
activateBuffer(id, SUB_VIEW, true);
|
||||
}
|
||||
activateBuffer(originalActiveBufferID, originalActiveView, true); // set back the original
|
||||
}
|
||||
|
||||
auto svp = NppParameters::getInstance().getSVP();
|
||||
if (svp._isChangeHistoryMarginEnabled || svp._isChangeHistoryIndicatorEnabled)
|
||||
clearChangesHistory();
|
||||
if (svp._isChangeHistoryMarginEnabled || svp._isChangeHistoryIndicatorEnabled)
|
||||
clearChangesHistory(otherView());
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user