]> git.mdlowis.com Git - projs/tide.git/commitdiff
Only select previous insert if the top of the undo stack is an insert. Also, lock...
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 23 Nov 2016 16:50:00 +0000 (11:50 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 23 Nov 2016 16:50:00 +0000 (11:50 -0500)
libedit/buf.c
libedit/view.c

index 52e240a0f09d748e7ae36e5b42ef62787ef5e862..7cf20a72335204570f354556a051db44fb5f1e7d 100644 (file)
@@ -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;
     }
index f35634c4da87434dbd3c51ade5eb14a350e5cd48..422f963461c5c45022f522abc9c6d09f94c24cc1 100644 (file)
@@ -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);