mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #8349 from lePerdu/completion-indent-adjust
This commit is contained in:
commit
2816bc8620
@ -494,7 +494,7 @@ static int insert_check(VimState *state)
|
|||||||
s->inserted_space = false;
|
s->inserted_space = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (can_cindent && cindent_on() && ctrl_x_mode == 0) {
|
if (can_cindent && cindent_on() && ctrl_x_mode == 0 && !compl_started) {
|
||||||
insert_do_cindent(s);
|
insert_do_cindent(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,6 +466,7 @@ describe('completion', function()
|
|||||||
]])
|
]])
|
||||||
expect('August')
|
expect('August')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("repeats correctly after backspace #2674", function ()
|
it("repeats correctly after backspace #2674", function ()
|
||||||
feed('o<C-x><C-u>Ja')
|
feed('o<C-x><C-u>Ja')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@ -712,6 +713,118 @@ describe('completion', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("does not indent until an item is selected #8345", function ()
|
||||||
|
-- Indents on "ind", unindents on "unind".
|
||||||
|
source([[
|
||||||
|
function! TestIndent()
|
||||||
|
let line = getline(v:lnum)
|
||||||
|
if (line =~ '^\s*ind')
|
||||||
|
return indent(v:lnum-1) + shiftwidth()
|
||||||
|
elseif (line =~ '^\s*unind')
|
||||||
|
return indent(v:lnum-1) - shiftwidth()
|
||||||
|
else
|
||||||
|
return indent(v:lnum-1)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
set indentexpr=TestIndent()
|
||||||
|
set indentkeys=o,O,!^F,=ind,=unind
|
||||||
|
set completeopt+=menuone
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- Give some words to complete.
|
||||||
|
feed("iinc uninc indent unindent<CR>")
|
||||||
|
|
||||||
|
-- Does not indent when "ind" is typed.
|
||||||
|
feed("in<C-X><C-N>")
|
||||||
|
-- Completion list is generated incorrectly if we send everything at once
|
||||||
|
-- via nvim_input(). So wait() before sending <BS>. #8480
|
||||||
|
wait()
|
||||||
|
feed("<BS>d")
|
||||||
|
|
||||||
|
screen:expect([[
|
||||||
|
inc uninc indent unindent |
|
||||||
|
ind^ |
|
||||||
|
{2:indent }{0: }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{3:-- Keyword Local completion (^N^P) }{4:match 1 of 2} |
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- Indents when the item is selected
|
||||||
|
feed("<C-Y>")
|
||||||
|
screen:expect([[
|
||||||
|
inc uninc indent unindent |
|
||||||
|
indent^ |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{3:-- INSERT --} |
|
||||||
|
]])
|
||||||
|
-- Indents when completion is exited using ESC.
|
||||||
|
feed("<CR>in<C-N><BS>d<Esc>")
|
||||||
|
screen:expect([[
|
||||||
|
inc uninc indent unindent |
|
||||||
|
indent |
|
||||||
|
in^d |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
-- Works for unindenting too.
|
||||||
|
feed("ounin<C-X><C-N>")
|
||||||
|
helpers.wait()
|
||||||
|
feed("<BS>d")
|
||||||
|
screen:expect([[
|
||||||
|
inc uninc indent unindent |
|
||||||
|
indent |
|
||||||
|
ind |
|
||||||
|
unind^ |
|
||||||
|
{0:~ }{2: unindent }{0: }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{3:-- Keyword Local completion (^N^P) }{4:match 1 of 2} |
|
||||||
|
]])
|
||||||
|
-- Works when going back and forth.
|
||||||
|
feed("<BS>c")
|
||||||
|
screen:expect([[
|
||||||
|
inc uninc indent unindent |
|
||||||
|
indent |
|
||||||
|
ind |
|
||||||
|
uninc^ |
|
||||||
|
{0:~ }{2: uninc }{0: }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{3:-- Keyword Local completion (^N^P) }{4:match 1 of 2} |
|
||||||
|
]])
|
||||||
|
feed("<BS>d")
|
||||||
|
screen:expect([[
|
||||||
|
inc uninc indent unindent |
|
||||||
|
indent |
|
||||||
|
ind |
|
||||||
|
unind^ |
|
||||||
|
{0:~ }{2: unindent }{0: }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{3:-- Keyword Local completion (^N^P) }{4:match 1 of 2} |
|
||||||
|
]])
|
||||||
|
feed("<C-N><C-N><C-Y><Esc>")
|
||||||
|
screen:expect([[
|
||||||
|
inc uninc indent unindent |
|
||||||
|
indent |
|
||||||
|
ind |
|
||||||
|
uninden^t |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
it('disables folding during completion', function ()
|
it('disables folding during completion', function ()
|
||||||
feed_command("set foldmethod=indent")
|
feed_command("set foldmethod=indent")
|
||||||
|
Loading…
Reference in New Issue
Block a user