aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-12 11:29:28 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-12 11:29:28 +0200
commit6df6386c3af1420d9b0d676d5b9da660ab6f99d4 (patch)
treee9b717be17c69d090b9cd1d2fda6841620407819 /vis.c
parentbc8ad2d9e83096685dac4a7af3b1080b012eb24d (diff)
downloadvis-6df6386c3af1420d9b0d676d5b9da660ab6f99d4.tar.gz
vis-6df6386c3af1420d9b0d676d5b9da660ab6f99d4.tar.xz
Restore cursor position after an undo/redo
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/vis.c b/vis.c
index 88cefd2..b2559d7 100644
--- a/vis.c
+++ b/vis.c
@@ -593,13 +593,21 @@ static void mark_line(const Arg *arg) {
}
static void undo(const Arg *arg) {
- if (text_undo(vis->win->text))
+ size_t pos = text_undo(vis->win->text);
+ if (pos != (size_t)-1) {
+ window_cursor_to(vis->win->win, pos);
+ /* redraw all windows in case some display the same file */
editor_draw(vis);
+ }
}
static void redo(const Arg *arg) {
- if (text_redo(vis->win->text))
+ size_t pos = text_redo(vis->win->text);
+ if (pos != (size_t)-1) {
+ window_cursor_to(vis->win->win, pos);
+ /* redraw all windows in case some display the same file */
editor_draw(vis);
+ }
}
static void zero(const Arg *arg) {