From: Michael D. Lowis Date: Wed, 23 Nov 2016 16:50:00 +0000 (-0500) Subject: Only select previous insert if the top of the undo stack is an insert. Also, lock... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=756ffbc887c7e55fbb8db9c98010c40d191883fb;p=projs%2Ftide.git Only select previous insert if the top of the undo stack is an insert. Also, lock the top undo when the selection is changed --- diff --git a/libedit/buf.c b/libedit/buf.c index 52e240a..7cf20a7 100644 --- a/libedit/buf.c +++ b/libedit/buf.c @@ -407,12 +407,7 @@ unsigned buf_setcol(Buf* buf, unsigned pos, unsigned col) { void buf_lastins(Buf* buf, size_t* beg, size_t* end) { Log* log = buf->undo; - while (log) { - if (log->insert) - break; - log = log->next; - } - if (log) { + if (log && log->insert) { *beg = log->data.ins.beg; *end = log->data.ins.end; } diff --git a/libedit/view.c b/libedit/view.c index f35634c..422f963 100644 --- a/libedit/view.c +++ b/libedit/view.c @@ -290,6 +290,7 @@ static void selcontext(View* view, Sel* sel) { } void view_selword(View* view, size_t row, size_t col) { + buf_loglock(&(view->buffer)); view_setcursor(view, row, col); Sel sel = view->selection; selbigword(view, &sel); @@ -298,12 +299,14 @@ void view_selword(View* view, size_t row, size_t col) { } void view_selprev(View* view) { + buf_loglock(&(view->buffer)); Sel sel = view->selection; buf_lastins(&(view->buffer), &sel.beg, &sel.end); view->selection = sel; } void view_select(View* view, size_t row, size_t col) { + buf_loglock(&(view->buffer)); view_setcursor(view, row, col); Sel sel = view->selection; selcontext(view, &sel);