aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2025-04-18 09:20:38 +1000
committerNeil <nyamatongwe@gmail.com>2025-04-18 09:20:38 +1000
commitc1de3774867127539b9b93efd4a0832a3f3a9fcf (patch)
tree8109f426718be98882a78c9369fbd9c4ca64224f /src
parentd36d669ddfd447fbbe28faef18457177bf102881 (diff)
downloadscintilla-mirror-c1de3774867127539b9b93efd4a0832a3f3a9fcf.tar.gz
Control restoring vertical scroll position for undo with
SC_UNDO_SELECTION_HISTORY_SCROLL flag to SCI_SETUNDOSELECTIONHISTORY.
Diffstat (limited to 'src')
-rw-r--r--src/EditModel.cxx2
-rw-r--r--src/Editor.cxx8
2 files changed, 6 insertions, 4 deletions
diff --git a/src/EditModel.cxx b/src/EditModel.cxx
index e12aab38e..65d39f9e7 100644
--- a/src/EditModel.cxx
+++ b/src/EditModel.cxx
@@ -172,7 +172,7 @@ int EditModel::GetMark(Sci::Line line) const {
}
void EditModel::EnsureModelState() {
- if (!modelState && (undoSelectionHistoryOption == UndoSelectionHistoryOption::Enabled)) {
+ if (!modelState && (undoSelectionHistoryOption != UndoSelectionHistoryOption::Disabled)) {
if (ViewStateShared vss = pdoc->GetViewState(this)) {
modelState = std::dynamic_pointer_cast<ModelState>(vss);
} else {
diff --git a/src/Editor.cxx b/src/Editor.cxx
index ead69617d..334600461 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -2409,12 +2409,14 @@ void Editor::SelectAll() {
void Editor::RestoreSelection(Sci::Position newPos, UndoRedo history) {
EnsureModelState();
- if ((undoSelectionHistoryOption == UndoSelectionHistoryOption::Enabled) && modelState) {
+ if (FlagSet(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 SelectionWithScroll selAndLine = modelState->SelectionFromStack(index, history);
if (!selAndLine.selection.empty()) {
- ScrollTo(selAndLine.topLine);
+ if (FlagSet(undoSelectionHistoryOption, UndoSelectionHistoryOption::Scroll)) {
+ ScrollTo(selAndLine.topLine);
+ }
sel = Selection(selAndLine.selection);
if (sel.IsRectangular()) {
const size_t mainForRectangular = sel.Main();
@@ -2799,7 +2801,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
view.llc.Invalidate(LineLayout::ValidLevel::checkTextAndStyle);
}
} else {
- if ((undoSelectionHistoryOption == UndoSelectionHistoryOption::Enabled) &&
+ if (FlagSet(undoSelectionHistoryOption, UndoSelectionHistoryOption::Enabled) &&
FlagSet(mh.modificationType, ModificationFlags::User)) {
if (FlagSet(mh.modificationType, ModificationFlags::BeforeInsert | ModificationFlags::BeforeDelete)) {
RememberSelectionForUndo(pdoc->UndoCurrent());