aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/EditModel.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2025-02-01 09:39:53 +1100
committerNeil <nyamatongwe@gmail.com>2025-02-01 09:39:53 +1100
commitdb6332fa9933244c45c44063afbdcccb462cfc03 (patch)
treeb09bb8f87572f084ad0e701745059351ed6e86d0 /src/EditModel.h
parentbd03d24f8bd44813db8ed1c73c5a46400d94a7cf (diff)
downloadscintilla-mirror-db6332fa9933244c45c44063afbdcccb462cfc03.tar.gz
Use string form for selection undo history as it saves significant space.
On average takes around 20% of SelectionSimple.
Diffstat (limited to 'src/EditModel.h')
-rw-r--r--src/EditModel.h23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/EditModel.h b/src/EditModel.h
index f75cece44..b9c331573 100644
--- a/src/EditModel.h
+++ b/src/EditModel.h
@@ -21,26 +21,15 @@ public:
Caret() noexcept;
};
-// Simplified version of selection which won't contain rectangular selection realized
-// into ranges as too much data.
-// Just a type and single range for now.
-
-struct SelectionSimple {
- std::vector<SelectionRange> ranges;
- SelectionRange rangeRectangular;
- size_t mainRange = 0;
- Selection::SelTypes selType = Selection::SelTypes::stream;
-
- SelectionSimple() = default;
- explicit SelectionSimple(const Selection &sel);
-};
-
enum class UndoRedo { undo, redo };
+// Selection stack is sparse so use a map
+using SelectionStack = std::map<int, std::string>;
+
struct SelectionHistory {
int indexCurrent = 0;
- SelectionSimple ssCurrent;
- std::map<int, SelectionSimple> stack;
+ std::string ssCurrent;
+ SelectionStack stack;
};
struct ModelState : ViewState {
@@ -50,7 +39,7 @@ struct ModelState : ViewState {
void ForgetSelectionForUndo() noexcept;
void RememberSelectionOntoStack(int index);
void RememberSelectionForRedoOntoStack(int index, const Selection &sel);
- const SelectionSimple *SelectionFromStack(int index, UndoRedo history) const;
+ std::string_view SelectionFromStack(int index, UndoRedo history) const;
virtual void TruncateUndo(int index) final;
};