mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.2.3935: CTRL-U in Insert mode does not fix the indent
Problem: CTRL-U in Insert mode does not fix the indent. Solution: Fix the indent when 'cindent' is set.
This commit is contained in:
15
src/edit.c
15
src/edit.c
@@ -3980,6 +3980,9 @@ ins_bs(
|
|||||||
int in_indent;
|
int in_indent;
|
||||||
int oldState;
|
int oldState;
|
||||||
int cpc[MAX_MCO]; // composing characters
|
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
|
* can't delete anything in an empty file
|
||||||
@@ -4161,7 +4164,13 @@ ins_bs(
|
|||||||
save_col = curwin->w_cursor.col;
|
save_col = curwin->w_cursor.col;
|
||||||
beginline(BL_WHITE);
|
beginline(BL_WHITE);
|
||||||
if (curwin->w_cursor.col < save_col)
|
if (curwin->w_cursor.col < save_col)
|
||||||
|
{
|
||||||
mincol = curwin->w_cursor.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;
|
curwin->w_cursor.col = save_col;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4333,6 +4342,12 @@ ins_bs(
|
|||||||
#endif
|
#endif
|
||||||
if (curwin->w_cursor.col <= 1)
|
if (curwin->w_cursor.col <= 1)
|
||||||
did_ai = FALSE;
|
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
|
* It's a little strange to put backspaces into the redo
|
||||||
* buffer, but it makes auto-indent a lot easier to deal
|
* buffer, but it makes auto-indent a lot easier to deal
|
||||||
|
@@ -238,7 +238,7 @@ func Test_format_c_comment()
|
|||||||
END
|
END
|
||||||
call assert_equal(expected, getline(1, '$'))
|
call assert_equal(expected, getline(1, '$'))
|
||||||
|
|
||||||
" Using "o" repeates the line comment, "O" does not.
|
" Using "o" repeats the line comment, "O" does not.
|
||||||
%del
|
%del
|
||||||
let text =<< trim END
|
let text =<< trim END
|
||||||
nop;
|
nop;
|
||||||
@@ -261,6 +261,21 @@ func Test_format_c_comment()
|
|||||||
END
|
END
|
||||||
call assert_equal(expected, getline(1, '$'))
|
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!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -749,6 +749,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3935,
|
||||||
/**/
|
/**/
|
||||||
3934,
|
3934,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user