]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2166: auto format doesn't work when deleting text v8.2.2166
authorBram Moolenaar <Bram@vim.org>
Sun, 20 Dec 2020 12:07:48 +0000 (13:07 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 20 Dec 2020 12:07:48 +0000 (13:07 +0100)
Problem:    Auto format doesn't work when deleting text.
Solution:   Make "x" trigger auto format. (closes #7504)

src/ops.c
src/testdir/test_textformat.vim
src/version.c

index b83394e01de277e8376b273bb8596c7fb4e9d373..743bdd43da56cc06ed85ba5ad485fa0fbdf3076c 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -938,6 +938,7 @@ op_delete(oparg_T *oap)
            curwin->w_cursor = curpos;  // restore curwin->w_cursor
            (void)do_join(2, FALSE, FALSE, FALSE, FALSE);
        }
+       auto_format(FALSE, TRUE);
     }
 
     msgmore(curbuf->b_ml.ml_line_count - old_lcount);
index a91c3da81c7a371f7e74d68fc06d22d1e8e8cd50..eac1c1980ab0025164a6e81a5ccaacf3574096cc 100644 (file)
@@ -934,6 +934,18 @@ func Test_fo_a_w()
   call assert_equal('g uu uu ', getline(1)[-8:])
   call assert_equal(['uu. foo'], getline(2, '$'))
 
+  " using backspace or "x" triggers reformat
+  call setline(1, ['1 2 3 4 5 ', '6 7 8 9'])
+  set tw=10
+  set fo=taw
+  set bs=indent,eol,start
+  exe "normal 1G4la\<BS>\<BS>\<Esc>"
+  call assert_equal(['1 2 4 5 6 ', '7 8 9'], getline(1, 2))
+  exe "normal f4xx"
+  call assert_equal(['1 2 5 6 7 ', '8 9'], getline(1, 2))
+
+  set tw=0
+  set fo&
   %bw!
 endfunc
 
index fe06be04973da30a20a067c6f4f5be58e82a2027..ac6fb1265bba4135ddd1839b094270681dc0274a 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2166,
 /**/
     2165,
 /**/