]> granicus.if.org Git - vim/commitdiff
patch 8.2.0083: text properties wrong when tabs and spaces are exchanged v8.2.0083
authorBram Moolenaar <Bram@vim.org>
Fri, 3 Jan 2020 20:25:59 +0000 (21:25 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 3 Jan 2020 20:25:59 +0000 (21:25 +0100)
Problem:    Text properties wrong when tabs and spaces are exchanged.
Solution:   Take text properties into account. (Nobuhiro Takasaki,
            closes #5427)

src/edit.c
src/testdir/test_textprop.vim
src/version.c

index c67f67cb393ea611447931550df497683cc6ff8f..d2e45dd2f0e19f803394bd5042e4b98ec7f67e32 100644 (file)
@@ -5601,14 +5601,20 @@ ins_tab(void)
            i = cursor->col - fpos.col;
            if (i > 0)
            {
-               STRMOVE(ptr, ptr + i);
+#ifdef FEAT_PROP_POPUP
+               if (!(State & VREPLACE_FLAG))
+               {
+                   mch_memmove(ptr, ptr + i, curbuf->b_ml.ml_line_len - i
+                                          - (ptr - curbuf->b_ml.ml_line_ptr));
+                   curbuf->b_ml.ml_line_len -= i;
+               }
+               else
+#endif
+                   STRMOVE(ptr, ptr + i);
                // correct replace stack.
                if ((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG))
                    for (temp = i; --temp >= 0; )
                        replace_join(repl_off);
-#ifdef FEAT_PROP_POPUP
-               curbuf->b_ml.ml_line_len -= i;
-#endif
            }
 #ifdef FEAT_NETBEANS_INTG
            if (netbeans_active())
index ded56a86009f90096dceb4da4ee6e9c4d8eecc45..54b42c1467e1893eae7c969dc2b56a6cde49f904 100644 (file)
@@ -925,3 +925,39 @@ func Test_proptype_substitute2()
   call assert_equal(expected, prop_list(1))
   bwipe!
 endfunc
+
+func Test_textprop_noexpandtab()
+  %bwipe!
+  new
+  let save_ts = &tabstop
+  set tabstop=8
+  let save_sts = &softtabstop
+  set softtabstop=4
+  let save_sw = &shiftwidth
+  set shiftwidth=4
+  let save_et = &expandtab
+  set noexpandtab
+  let save_fdm = &foldmethod
+  set foldmethod=marker
+  call feedkeys("\<esc>\<esc>0Ca\<cr>\<esc>\<up>", "tx")
+  call prop_type_add('test', {'highlight': 'ErrorMsg'})
+  call prop_add(1, 1, {'end_col': 2, 'type': 'test'})
+  call feedkeys("0i\<tab>", "tx")
+  call prop_remove({'type': 'test'})
+  call prop_add(1, 2, {'end_col': 3, 'type': 'test'})
+  call feedkeys("A\<left>\<tab>", "tx")
+  call prop_remove({'type': 'test'})
+  try
+    " It is correct that this does not pass
+    call prop_add(1, 6, {'end_col': 7, 'type': 'test'})
+    " Has already collapsed here, start_col:6 does not result in an error
+    call feedkeys("A\<left>\<tab>", "tx")
+  catch /^Vim\%((\a\+)\)\=:E964/
+  endtry
+  call prop_remove({'type': 'test'})
+  let &foldmethod = save_fdm
+  let &expandtab = save_et
+  let &shiftwidth = save_sw
+  let &softtabstop = save_sts
+  let &tabstop = save_ts
+endfunc
index 6dd07bb686080a0e95392df863cad12b3b401e25..3c8feee7c057b7edb5f31d623e859a65fe8040fc 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    83,
 /**/
     82,
 /**/