From 2adc5efe2b80b48c9cdb7648ad377832d93b36ae Mon Sep 17 00:00:00 2001 From: ForLoveOfCats Date: Sun, 24 Apr 2022 20:35:59 -0400 Subject: LibGUI: Don't merge TextDocumentUndoCommand if too much time has elapsed --- Userland/Libraries/LibGUI/TextDocument.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Userland/Libraries/LibGUI/TextDocument.h') diff --git a/Userland/Libraries/LibGUI/TextDocument.h b/Userland/Libraries/LibGUI/TextDocument.h index c024c85090..dc24141fab 100644 --- a/Userland/Libraries/LibGUI/TextDocument.h +++ b/Userland/Libraries/LibGUI/TextDocument.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,8 @@ namespace GUI { +constexpr Time COMMAND_COMMIT_TIME = Time::from_milliseconds(400); + struct TextDocumentSpan { TextRange range; Gfx::TextAttributes attributes; @@ -202,6 +205,9 @@ public: } protected: + bool commit_time_expired() const { return Time::now_monotonic() - m_timestamp >= COMMAND_COMMIT_TIME; } + + Time m_timestamp = Time::now_monotonic(); TextDocument& m_document; TextDocument::Client const* m_client { nullptr }; }; -- cgit v1.2.3