mirror of
https://github.com/neovim/neovim.git
synced 2024-12-21 19:55:04 -07:00
vim-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.
5d20fbf2e7
This commit is contained in:
parent
da3b04a9e0
commit
f7801fe138
@ -8299,6 +8299,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|
||||
int in_indent;
|
||||
int oldState;
|
||||
int cpc[MAX_MCO]; // composing characters
|
||||
bool call_fix_indent = false;
|
||||
|
||||
// can't delete anything in an empty file
|
||||
// can't backup past first character in buffer
|
||||
@ -8442,6 +8443,8 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|
||||
beginline(BL_WHITE);
|
||||
if (curwin->w_cursor.col < save_col) {
|
||||
mincol = curwin->w_cursor.col;
|
||||
// should now fix the indent to match with the previous line
|
||||
call_fix_indent = true;
|
||||
}
|
||||
curwin->w_cursor.col = save_col;
|
||||
}
|
||||
@ -8576,6 +8579,11 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|
||||
if (curwin->w_cursor.col <= 1) {
|
||||
did_ai = false;
|
||||
}
|
||||
|
||||
if (call_fix_indent) {
|
||||
fix_indent();
|
||||
}
|
||||
|
||||
// It's a little strange to put backspaces into the redo
|
||||
// buffer, but it makes auto-indent a lot easier to deal
|
||||
// with.
|
||||
|
@ -238,7 +238,7 @@ func Test_format_c_comment()
|
||||
END
|
||||
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
|
||||
let text =<< trim END
|
||||
nop;
|
||||
@ -261,6 +261,21 @@ func Test_format_c_comment()
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user