From e2720f1fbe09649e6da282cd33b9794867d3d0fb Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 27 Sep 2015 11:55:34 +0100 Subject: Store timespec for buffer fs timestamps, not just time_t time_t has a resolution of one second, which cause troubles when a file changes multiple time during that same second. --- src/buffer.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/buffer.hh') diff --git a/src/buffer.hh b/src/buffer.hh index ba5a62df..5342dd83 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -14,7 +14,7 @@ namespace Kakoune class Buffer; -constexpr time_t InvalidTime = 0; +constexpr timespec InvalidTime = { -1, -1 }; // A BufferIterator permits to iterate over the characters of a buffer class BufferIterator @@ -79,7 +79,7 @@ public: }; Buffer(String name, Flags flags, BufferLines lines = {}, - time_t fs_timestamp = InvalidTime); + timespec fs_timestamp = InvalidTime); Buffer(const Buffer&) = delete; Buffer& operator= (const Buffer&) = delete; ~Buffer(); @@ -93,8 +93,8 @@ public: BufferIterator erase(BufferIterator begin, BufferIterator end); size_t timestamp() const; - time_t fs_timestamp() const; - void set_fs_timestamp(time_t ts); + timespec fs_timestamp() const; + void set_fs_timestamp(timespec ts); void commit_undo_group(); bool undo(); @@ -152,7 +152,7 @@ public: void run_hook_in_own_context(StringView hook_name, StringView param); - void reload(BufferLines lines, time_t fs_timestamp = InvalidTime); + void reload(BufferLines lines, timespec fs_timestamp = InvalidTime); void check_invariant() const; @@ -213,7 +213,7 @@ private: Vector m_changes; - time_t m_fs_timestamp; + timespec m_fs_timestamp; // Values are just data holding by the buffer, they are not part of its // observable state -- cgit v1.2.3