Patch 8.2.3935

5 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 29, 2021, 11:06:04 AM12/29/21
to vim...@googlegroups.com

Patch 8.2.3935
Problem: CTRL-U in Insert mode does not fix the indent.
Solution: Fix the indent when 'cindent' is set.
Files: src/edit.c, src/testdir/test_textformat.vim


*** ../vim-8.2.3934/src/edit.c 2021-12-27 17:21:38.004449137 +0000
--- src/edit.c 2021-12-29 15:45:34.736170848 +0000
***************
*** 3980,3985 ****
--- 3980,3988 ----
int in_indent;
int oldState;
int cpc[MAX_MCO]; // composing characters
+ #if defined(FEAT_LISP) || defined(FEAT_CINDENT)
+ int call_fix_indent = FALSE;
+ #endif

/*
* can't delete anything in an empty file
***************
*** 4161,4167 ****
--- 4164,4176 ----
save_col = curwin->w_cursor.col;
beginline(BL_WHITE);
if (curwin->w_cursor.col < save_col)
+ {
mincol = curwin->w_cursor.col;
+ #if defined(FEAT_LISP) || defined(FEAT_CINDENT)
+ // should now fix the indent to match with the previous line
+ call_fix_indent = TRUE;
+ #endif
+ }
curwin->w_cursor.col = save_col;
}

***************
*** 4333,4338 ****
--- 4342,4353 ----
#endif
if (curwin->w_cursor.col <= 1)
did_ai = FALSE;
+
+ #if defined(FEAT_LISP) || defined(FEAT_CINDENT)
+ if (call_fix_indent)
+ fix_indent();
+ #endif
+
/*
* It's a little strange to put backspaces into the redo
* buffer, but it makes auto-indent a lot easier to deal
*** ../vim-8.2.3934/src/testdir/test_textformat.vim 2021-12-29 15:15:44.059212358 +0000
--- src/testdir/test_textformat.vim 2021-12-29 15:55:39.139157927 +0000
***************
*** 238,244 ****
END
call assert_equal(expected, getline(1, '$'))

! " Using "o" repeates the line comment, "O" does not.
%del
let text =<< trim END
nop;
--- 238,244 ----
END
call assert_equal(expected, getline(1, '$'))

! " Using "o" repeats the line comment, "O" does not.
%del
let text =<< trim END
nop;
***************
*** 261,266 ****
--- 261,281 ----
END
call assert_equal(expected, getline(1, '$'))

+ " Using CTRL-U after "o" fixes the indent
+ %del
+ let text =<< trim END
+ {
+ val = val; // This is a comment
+ END
+ call setline(1, text)
+ exe "normal! 2Go\<C-U>x\<Esc>"
+ let expected =<< trim END
+ {
+ val = val; // This is a comment
+ x
+ END
+ call assert_equal(expected, getline(1, '$'))
+
bwipe!
endfunc

*** ../vim-8.2.3934/src/version.c 2021-12-29 15:15:44.059212358 +0000
--- src/version.c 2021-12-29 15:46:31.940070503 +0000
***************
*** 751,752 ****
--- 751,754 ----
{ /* Add new patch number below this line */
+ /**/
+ 3935,
/**/

--
hundred-and-one symptoms of being an internet addict:
138. You develop a liking for cold coffee.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages