diff options
| author | Frank LENORMAND <lenormf@gmail.com> | 2019-11-23 15:55:46 +0100 |
|---|---|---|
| committer | Frank LENORMAND <lenormf@gmail.com> | 2019-12-03 17:05:24 +0100 |
| commit | e1bd076f5e64010578b904ad4bbb25b462517ef3 (patch) | |
| tree | dd5bf7dea95a2e58a8342bd0a10c01166232a25a /src/buffer.cc | |
| parent | 936bd923eae554d83dc77ab788d84b6d83c108f9 (diff) | |
src: Reload buffers when their contents' hash changes
Instead of triggering a reload event when the timestamp of a buffer's
underlying file changes, do so when its contents are actually modified.
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index 6088c8a8..4e966a1a 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -78,7 +78,7 @@ Buffer::Buffer(String name, Flags flags, StringView data, m_history{{HistoryId::Invalid}}, m_history_id{HistoryId::First}, m_last_save_history_id{HistoryId::First}, - m_fs_timestamp{fs_timestamp.tv_sec, fs_timestamp.tv_nsec} + m_fs_status{fs_timestamp, data.length(), hash_value(data)} { ParsedLines parsed_lines = parse_lines(data); @@ -122,7 +122,7 @@ void Buffer::on_registered() run_hook_in_own_context(Hook::BufNewFile, m_name); else { - kak_assert(m_fs_timestamp != InvalidTime); + kak_assert(m_fs_status.timestamp != InvalidTime); run_hook_in_own_context(Hook::BufOpenFile, m_name); } } @@ -305,7 +305,7 @@ void Buffer::reload(StringView data, timespec fs_timestamp) apply_options(options(), parsed_lines); m_last_save_history_id = m_history_id; - m_fs_timestamp = fs_timestamp; + m_fs_status = {fs_timestamp, data.length(), hash_value(data)}; } void Buffer::commit_undo_group() @@ -607,7 +607,7 @@ void Buffer::notify_saved() m_flags &= ~Flags::New; m_last_save_history_id = m_history_id; - m_fs_timestamp = get_fs_timestamp(m_name); + m_fs_status.timestamp = get_fs_timestamp(m_name); } BufferCoord Buffer::advance(BufferCoord coord, ByteCount count) const @@ -663,16 +663,16 @@ BufferCoord Buffer::char_prev(BufferCoord coord) const return { coord.line, column }; } -timespec Buffer::fs_timestamp() const +void Buffer::set_fs_status(FsStatus status) { kak_assert(m_flags & Flags::File); - return m_fs_timestamp; + m_fs_status = std::move(status); } -void Buffer::set_fs_timestamp(timespec ts) +const FsStatus& Buffer::fs_status() const { kak_assert(m_flags & Flags::File); - m_fs_timestamp = ts; + return m_fs_status; } void Buffer::on_option_changed(const Option& option) |
