From 33c58c50c7f1e700d6125a77a5650e06ed44b349 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 15 Jun 2017 13:22:07 -0400 Subject: [PATCH] hack attempt to squash crappy behavior of undo/redo with line number syncing. Need unit tests to really iron out the issues. --- lib/view.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/view.c b/lib/view.c index 3536ed9..cd1c978 100644 --- a/lib/view.c +++ b/lib/view.c @@ -272,17 +272,25 @@ void view_setln(View* view, size_t line) { } void view_undo(View* view) { + view->prev_csr = view->selection.end; buf_undo(&(view->buffer), &(view->selection)); - view_jumpto(view, true, view->selection.end); - view->sync_center = !selection_visible(view); - sync_line_numbers(view, 0); + view->sync_lines = true; + if (!selection_visible(view)) { + view->sync_center = true; + if (view->nrows) + view->rows[0]->off = buf_bol(&(view->buffer), view->selection.beg); + } } void view_redo(View* view) { + view->prev_csr = view->selection.end; buf_redo(&(view->buffer), &(view->selection)); - view_jumpto(view, true, view->selection.end); - view->sync_center = !selection_visible(view); - sync_line_numbers(view, 0); + view->sync_lines = true; + if (!selection_visible(view)) { + view->sync_center = true; + if (view->nrows) + view->rows[0]->off = buf_bol(&(view->buffer), view->selection.beg); + } } void view_putstr(View* view, char* str) { -- 2.49.0