From: Michael D. Lowis Date: Thu, 15 Jun 2017 17:22:07 +0000 (-0400) Subject: hack attempt to squash crappy behavior of undo/redo with line number syncing. Need... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=33c58c50c7f1e700d6125a77a5650e06ed44b349;p=projs%2Ftide.git hack attempt to squash crappy behavior of undo/redo with line number syncing. Need unit tests to really iron out the issues. --- 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) {