diff options
| author | Albert Cervin <albert@acervin.com> | 2025-11-26 22:07:54 +0100 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2025-11-26 22:07:54 +0100 |
| commit | b8f2c54675cfd4c89c13941503fb23eda0ad082d (patch) | |
| tree | 59099bd756bb1b9f79b4438045e7060a541f66e0 /src | |
| parent | 54954cf0d9c73fc72cbce463a632b042a4959bcd (diff) | |
| download | dged-b8f2c54675cfd4c89c13941503fb23eda0ad082d.tar.gz dged-b8f2c54675cfd4c89c13941503fb23eda0ad082d.tar.xz dged-b8f2c54675cfd4c89c13941503fb23eda0ad082d.zip | |
Improve undo a bit by using non-alphanumeric chars
When typing a non-alphanumeric char manually, we add a undo boundary
to not be too greedy.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dged/buffer_view.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/dged/buffer_view.c b/src/dged/buffer_view.c index 76a3b5b..2d38ac8 100644 --- a/src/dged/buffer_view.c +++ b/src/dged/buffer_view.c @@ -1,3 +1,4 @@ +#include <ctype.h> #include <string.h> #include "buffer.h" @@ -5,7 +6,6 @@ #include "display.h" #include "settings.h" #include "timers.h" -#include "utf8.h" HOOK_IMPL(modeline, modeline_hook_cb); @@ -61,8 +61,11 @@ void buffer_view_add(struct buffer_view *view, uint8_t *txt, uint32_t nbytes) { maybe_delete_region(view); struct location before = view->dot; view->dot = buffer_add(view->buffer, view->dot, txt, nbytes); + if (view->dot.line > before.line) { buffer_push_undo_boundary(view->buffer); + } else if (nbytes == 1 && !isalnum(txt[0])) { + buffer_push_undo_boundary(view->buffer); } } |
