summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/TextDocument.h
diff options
context:
space:
mode:
authorForLoveOfCats <floc@unpromptedtirade.com>2022-04-24 20:35:59 -0400
committerAndreas Kling <kling@serenityos.org>2022-04-26 19:13:22 +0200
commit2adc5efe2b80b48c9cdb7648ad377832d93b36ae (patch)
tree9a6b6a22c9bb2609e266f1c3af1c03e30dbf46d5 /Userland/Libraries/LibGUI/TextDocument.h
parentee81c1b07a9cadc76b0b8a82ff81cbe6a0036466 (diff)
downloadserenity-2adc5efe2b80b48c9cdb7648ad377832d93b36ae.zip
LibGUI: Don't merge TextDocumentUndoCommand if too much time has elapsed
Diffstat (limited to 'Userland/Libraries/LibGUI/TextDocument.h')
-rw-r--r--Userland/Libraries/LibGUI/TextDocument.h6
1 files changed, 6 insertions, 0 deletions
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 <AK/NonnullRefPtr.h>
#include <AK/Optional.h>
#include <AK/RefCounted.h>
+#include <AK/Time.h>
#include <AK/Utf32View.h>
#include <LibCore/Forward.h>
#include <LibGUI/Command.h>
@@ -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 };
};