Browse code

bugfix: inserting in the space after the last character of the line now doesn't move selections after the insertion point

Dario Rodriguez authored on 07/01/2022 18:15:46
Showing 1 changed files
... ...
@@ -645,11 +645,6 @@ re_textinsert(re_t *re, char *text, int sizetext)
645 645
         }
646 646
         fixsel=0;
647 647
         selstart=selend=0;
648
-        if(re->selactive
649
-          && redata_linecol2pos(re->data,re->sellinefrom,re->selcolfrom,&selstart,NULL)==0
650
-          && redata_linecol2pos(re->data,re->sellineto,re->selcolto,&selend,NULL)==0) {
651
-                fixsel=1;
652
-        }
653 648
         at_end=(cursorpos==realend)?1:0;
654 649
         for(nspaces=0;nspaces<sizetext && text[nspaces]==' ';nspaces++)
655 650
                 ;
... ...
@@ -668,6 +663,11 @@ re_textinsert(re_t *re, char *text, int sizetext)
668 663
                 /* increment cursorpos; spaces are 1 byte, so the number of columns advanced is the number of bytes advanced */
669 664
                 cursorpos+=re->curcol-col;
670 665
         }
666
+        if(re->selactive
667
+          && redata_linecol2pos(re->data,re->sellinefrom,re->selcolfrom,&selstart,NULL)==0
668
+          && redata_linecol2pos(re->data,re->sellineto,re->selcolto,&selend,NULL)==0) {
669
+                fixsel=1;
670
+        }
671 671
         if(redata_op_add(re->data,cursorpos,text,sizetext,NULL)!=0)
672 672
                 return(-1); /* couldn't add requested text */
673 673
         /* fix selection */