]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0477: block_editing errors out when using <enter> v9.1.0477
authorChristian Brabandt <cb@256bit.org>
Tue, 11 Jun 2024 18:30:14 +0000 (20:30 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 11 Jun 2024 18:37:59 +0000 (20:37 +0200)
Problem:  block_editing errors out when using <enter>
          (Ali Rizvi-Santiago, after v9.1.0274)
Solution: Change ins_len from size_t to int so that the test
          if ins_len is negative actually works properly

Add a test, so that this doesn't regress.

fixes: #14960

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ops.c
src/testdir/test_visual.vim
src/version.c

index b9569571ef917f9eb968bdfd2961485c53dd8b48..eb75c34b1bdbae548a8a91d6167c2b7fb4c9518d 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -1814,7 +1814,7 @@ op_change(oparg_T *oap)
      */
     if (oap->block_mode && oap->start.lnum != oap->end.lnum && !got_int)
     {
-       size_t  ins_len;
+       int     ins_len;
 
        // Auto-indenting may have changed the indent.  If the cursor was past
        // the indent, exclude that indent change from the inserted text.
@@ -1827,7 +1827,7 @@ op_change(oparg_T *oap)
            bd.textcol += new_indent - pre_indent;
        }
 
-       ins_len = ml_get_len(oap->start.lnum) - pre_textlen;
+       ins_len = (int)ml_get_len(oap->start.lnum) - pre_textlen;
        if (ins_len > 0)
        {
            // Subsequent calls to ml_get() flush the firstline data - take a
index 95ac9a6a83663217dcaed48d3f026156558847d1..3750ebf6b9986e46304503f4fd6d5e430791e950 100644 (file)
@@ -2705,4 +2705,13 @@ func Test_visual_block_cursor_delete()
   bwipe!
 endfunc
 
+func Test_visual_block_cursor_insert_enter()
+  new
+  call setline(1, ['asdf asdf', 'asdf asdf', 'asdf asdf', 'asdf asdf'])
+  call cursor(1, 5)
+  exe ":norm! \<c-v>3jcw\<cr>"
+  call assert_equal(['asdfw', 'asdf', 'asdfasdf', 'asdfasdf', 'asdfasdf'], getline(1, '$'))
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 12dc57596c1c460a4166ab1c4f028774d1394769..cc2494521d77817009d09cd5c8fd3301100bd781 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    477,
 /**/
     476,
 /**/