From f2bc1988dba5ca23692020017aa6f9ee2b4d71cf Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 25 Jan 2025 08:40:06 +1100 Subject: Bug [#1224]. Use enum for undo selection history and make API names more consistent as 'undo selection' instead of 'selection undo' as more closely associated with undo than selection. --- src/EditModel.cxx | 2 +- src/EditModel.h | 2 +- src/Editor.cxx | 13 +++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/EditModel.cxx b/src/EditModel.cxx index 60848e6dc..1f9c2d064 100644 --- a/src/EditModel.cxx +++ b/src/EditModel.cxx @@ -181,7 +181,7 @@ int EditModel::GetMark(Sci::Line line) const { } void EditModel::EnsureModelState() { - if (!modelState && rememberingSelectionForUndo) { + if (!modelState && (undoSelectionHistoryOption == UndoSelectionHistoryOption::Enabled)) { if (ViewStateShared vss = pdoc->GetViewState(this)) { modelState = std::dynamic_pointer_cast(vss); } else { diff --git a/src/EditModel.h b/src/EditModel.h index 716fd5788..f75cece44 100644 --- a/src/EditModel.h +++ b/src/EditModel.h @@ -92,7 +92,7 @@ public: Document *pdoc; - bool rememberingSelectionForUndo = false; + Scintilla::UndoSelectionHistoryOption undoSelectionHistoryOption = UndoSelectionHistoryOption::Disabled; bool needRedoRemembered = false; ModelStateShared modelState; diff --git a/src/Editor.cxx b/src/Editor.cxx index 8a7b15719..d63f43f3f 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2399,7 +2399,7 @@ void Editor::SelectAll() { } void Editor::RestoreSelection(Sci::Position newPos, UndoRedo history) { - if (rememberingSelectionForUndo && modelState) { + if ((undoSelectionHistoryOption == UndoSelectionHistoryOption::Enabled) && modelState) { // Undo wants the element after the current as it just undid it const int index = pdoc->UndoCurrent() + (history == UndoRedo::undo ? 1 : 0); const SelectionSimple *pss = modelState->SelectionFromStack(index, history); @@ -2789,7 +2789,8 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { view.llc.Invalidate(LineLayout::ValidLevel::checkTextAndStyle); } } else { - if (rememberingSelectionForUndo && FlagSet(mh.modificationType, ModificationFlags::User)) { + if ((undoSelectionHistoryOption == UndoSelectionHistoryOption::Enabled) && + FlagSet(mh.modificationType, ModificationFlags::User)) { if (FlagSet(mh.modificationType, ModificationFlags::BeforeInsert | ModificationFlags::BeforeDelete)) { RememberSelectionForUndo(pdoc->UndoCurrent()); } @@ -8687,12 +8688,12 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { case Message::GetChangeHistory: return static_cast(changeHistoryOption); - case Message::SetSelectionUndoHistory: - rememberingSelectionForUndo = wParam; + case Message::SetUndoSelectionHistory: + undoSelectionHistoryOption = static_cast(wParam); break; - case Message::GetSelectionUndoHistory: - return rememberingSelectionForUndo; + case Message::GetUndoSelectionHistory: + return static_cast(undoSelectionHistoryOption); case Message::SetExtraAscent: vs.extraAscent = static_cast(wParam); -- cgit v1.2.3