diff options
author | Neil <nyamatongwe@gmail.com> | 2024-02-09 21:25:16 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2024-02-09 21:25:16 +1100 |
commit | 8df2193739e8e37b0ab4c0c31a0e1741351c801f (patch) | |
tree | df8ec6858a499c3318d51df3c90d6f04f82a6d4b /src/UndoHistory.h | |
parent | c57d85c5a8872d192c11f7020ef7c13fbefff206 (diff) | |
download | scintilla-mirror-8df2193739e8e37b0ab4c0c31a0e1741351c801f.tar.gz |
Avoid overhead of extra start actions that delimited user operations. Now relies
on mayCoalesce flag to indicate that a user operation is complete when false.
Diffstat (limited to 'src/UndoHistory.h')
-rw-r--r-- | src/UndoHistory.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/UndoHistory.h b/src/UndoHistory.h index d9f4d37ce..03bea3de3 100644 --- a/src/UndoHistory.h +++ b/src/UndoHistory.h @@ -47,10 +47,12 @@ struct UndoActions { ScaledVector lengths; UndoActions() noexcept; - void resize(size_t length); - [[nodiscard]] size_t size() const noexcept; - void CreateStart(size_t index) noexcept; - void Create(size_t index, ActionType at_, Sci::Position position_=0, Sci::Position lenData_=0, bool mayCoalesce_=true); + void Truncate(size_t length) noexcept; + void PushBack(); + void Clear() noexcept; + [[nodiscard]] intptr_t SSize() const noexcept; + void Create(size_t index, ActionType at_, Sci::Position position_, Sci::Position lenData_, bool mayCoalesce_); + [[nodiscard]] bool AtStart(size_t index) const noexcept; }; class ScrapStack { @@ -70,7 +72,6 @@ public: */ class UndoHistory { UndoActions actions; - int maxAction = 0; int currentAction = 0; int undoSequenceDepth = 0; int savePoint = 0; @@ -78,7 +79,7 @@ class UndoHistory { std::optional<int> detach; std::unique_ptr<ScrapStack> scraps; - void EnsureUndoRoom(); + int PreviousAction() const noexcept; public: UndoHistory(); @@ -86,8 +87,8 @@ public: const char *AppendAction(ActionType at, Sci::Position position, const char *data, Sci::Position lengthData, bool &startSequence, bool mayCoalesce=true); - void BeginUndoAction(); - void EndUndoAction(); + void BeginUndoAction() noexcept; + void EndUndoAction() noexcept; void DropUndoSequence() noexcept; void DeleteUndoHistory() noexcept; @@ -96,15 +97,17 @@ public: void SetSavePoint() noexcept; bool IsSavePoint() const noexcept; bool BeforeSavePoint() const noexcept; + bool BeforeOrAtSavePoint() const noexcept; bool BeforeReachableSavePoint() const noexcept; bool AfterSavePoint() const noexcept; bool AfterDetachPoint() const noexcept; + bool AfterOrAtDetachPoint() const noexcept; // Tentative actions are used for input composition so that it can be undone cleanly void TentativeStart() noexcept; void TentativeCommit() noexcept; bool TentativeActive() const noexcept; - int TentativeSteps() noexcept; + int TentativeSteps() const noexcept; /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is /// called that many times. Similarly for redo. |