From c27f5c5ed4bce91eaa50d7d1daa5335f186dcc36 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Wed, 24 Jan 2024 13:00:09 +0100 Subject: Relative find file and small fixes - Save text was not always displaying - Files were sometimes not reloaded properly --- src/dged/buffer.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/dged/buffer.c') diff --git a/src/dged/buffer.c b/src/dged/buffer.c index f1ce2ce..8e63e1f 100644 --- a/src/dged/buffer.c +++ b/src/dged/buffer.c @@ -356,11 +356,10 @@ void buffer_reload(struct buffer *buffer) { return; } - if (sb.st_mtim.tv_sec != buffer->last_write.tv_sec) { + if (sb.st_mtim.tv_sec != buffer->last_write.tv_sec || + sb.st_mtim.tv_nsec != buffer->last_write.tv_nsec) { text_clear(buffer->text); buffer_read_from_file(buffer); - } else { - minibuffer_echo_timeout(2, "buffer %s not changed", buffer->filename); } } @@ -488,9 +487,20 @@ struct location buffer_next_line(struct buffer *buffer, struct location dot) { struct location buffer_clamp(struct buffer *buffer, int64_t line, int64_t col) { struct location location = {.line = 0, .col = 0}; + if (buffer_is_empty(buffer)) { + return location; + } + movev(buffer, line, &location); moveh(buffer, col, &location); + // when clamping we want to stay inside + // the actual bounds + if (location.line >= buffer_num_lines(buffer)) { + location.line = buffer_num_lines(buffer) - 1; + location.col = buffer_num_chars(buffer, location.line); + } + return location; } -- cgit v1.2.3