mirror of
https://github.com/vim/vim.git
synced 2025-10-20 08:14:18 -04:00
patch 9.1.1859: completion: whitespace not cleared with 'ai'
Problem: completion: whitespace not cleared with 'ai' Solution: Remove spaces added by 'autoindent' when autocomplete is set and restore did_ai in ins_compl_start() (Maxim Kim) fixes #18560 closes: #18582 Signed-off-by: Maxim Kim <habamax@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
b3b47e540d
commit
6180d65751
@@ -7115,7 +7115,10 @@ ins_compl_start(void)
|
|||||||
can_si = FALSE;
|
can_si = FALSE;
|
||||||
can_si_back = FALSE;
|
can_si_back = FALSE;
|
||||||
if (stop_arrow() == FAIL)
|
if (stop_arrow() == FAIL)
|
||||||
|
{
|
||||||
|
did_ai = save_did_ai;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
line = ml_get(curwin->w_cursor.lnum);
|
line = ml_get(curwin->w_cursor.lnum);
|
||||||
curs_col = curwin->w_cursor.col;
|
curs_col = curwin->w_cursor.col;
|
||||||
@@ -7205,6 +7208,7 @@ ins_compl_start(void)
|
|||||||
{
|
{
|
||||||
VIM_CLEAR_STRING(compl_pattern);
|
VIM_CLEAR_STRING(compl_pattern);
|
||||||
VIM_CLEAR_STRING(compl_orig_text);
|
VIM_CLEAR_STRING(compl_orig_text);
|
||||||
|
did_ai = save_did_ai;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7220,6 +7224,7 @@ ins_compl_start(void)
|
|||||||
out_flush();
|
out_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
did_ai = save_did_ai;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -458,6 +458,33 @@ func Test_autoindent_remove_indent()
|
|||||||
call delete('Xarifile')
|
call delete('Xarifile')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for autoindent removing indent when insert mode is stopped and
|
||||||
|
" autocomplete is enabled. Some parts of the code is exercised only when
|
||||||
|
" interactive mode is used. So use Vim in a terminal.
|
||||||
|
func Test_autoindent_remove_indent_with_autocomplete()
|
||||||
|
CheckRunVimInTerminal
|
||||||
|
let buf = RunVimInTerminal('-N Xarifile', {'rows': 6, 'cols' : 20})
|
||||||
|
call TermWait(buf)
|
||||||
|
call term_sendkeys(buf, ":set autoindent autocomplete\n")
|
||||||
|
" leaving insert mode in a new line with indent added by autoindent, should
|
||||||
|
" remove the indent.
|
||||||
|
call term_sendkeys(buf, "i\<Tab>foo\<CR>\<Esc>")
|
||||||
|
" Need to delay for some time, otherwise the code in getchar.c will not be
|
||||||
|
" exercised.
|
||||||
|
call TermWait(buf, 50)
|
||||||
|
" when a line is wrapped and the cursor is at the start of the second line,
|
||||||
|
" leaving insert mode, should move the cursor back to the first line.
|
||||||
|
call term_sendkeys(buf, "o" .. repeat('x', 20) .. "\<Esc>")
|
||||||
|
" Need to delay for some time, otherwise the code in getchar.c will not be
|
||||||
|
" exercised.
|
||||||
|
call TermWait(buf, 50)
|
||||||
|
call term_sendkeys(buf, ":w\n")
|
||||||
|
call TermWait(buf)
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call assert_equal(["\tfoo", '', repeat('x', 20)], readfile('Xarifile'))
|
||||||
|
call delete('Xarifile')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_edit_esc_after_CR_autoindent()
|
func Test_edit_esc_after_CR_autoindent()
|
||||||
new
|
new
|
||||||
setlocal autoindent
|
setlocal autoindent
|
||||||
|
@@ -734,6 +734,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 */
|
||||||
|
/**/
|
||||||
|
1859,
|
||||||
/**/
|
/**/
|
||||||
1858,
|
1858,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user