diff options
| author | Albert Cervin <albert@acervin.com> | 2024-01-24 13:00:09 +0100 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2024-01-24 13:00:09 +0100 |
| commit | c27f5c5ed4bce91eaa50d7d1daa5335f186dcc36 (patch) | |
| tree | 93f7ecb1e7d1ebb792d767255b27c1742745204a /src/dged/buffer.c | |
| parent | 64d6816a36567274551dd4f067fe4d05b1445cc0 (diff) | |
| download | dged-c27f5c5ed4bce91eaa50d7d1daa5335f186dcc36.tar.gz dged-c27f5c5ed4bce91eaa50d7d1daa5335f186dcc36.tar.xz dged-c27f5c5ed4bce91eaa50d7d1daa5335f186dcc36.zip | |
Relative find file and small fixes
- Save text was not always displaying
- Files were sometimes not reloaded properly
Diffstat (limited to 'src/dged/buffer.c')
| -rw-r--r-- | src/dged/buffer.c | 16 |
1 files changed, 13 insertions, 3 deletions
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; } |
