mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.1.1145: multi-line completion has wrong indentation for last line
Problem: When expanding omni completion items with newlines (e.g. `then\n\t\nend`), the end statement gets wrong indentation. Solution: Add OPENLINE_FORCE_INDENT flag to make open_line() use second_line_indent directly (glepnir) closes: #16614 Signed-off-by: glepnir <glephunter@gmail.com> Signed-off-by: Justin M. Keyes <justinkz@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
5b97947bbd
commit
5090a1fecb
@@ -1385,6 +1385,8 @@ del_bytes(
|
|||||||
* OPENLINE_KEEPTRAIL keep trailing spaces
|
* OPENLINE_KEEPTRAIL keep trailing spaces
|
||||||
* OPENLINE_MARKFIX adjust mark positions after the line break
|
* OPENLINE_MARKFIX adjust mark positions after the line break
|
||||||
* OPENLINE_COM_LIST format comments with list or 2nd line indent
|
* OPENLINE_COM_LIST format comments with list or 2nd line indent
|
||||||
|
* OPENLINE_FORCE_INDENT set indent from second_line_indent, ignore
|
||||||
|
* 'autoindent'
|
||||||
*
|
*
|
||||||
* "second_line_indent": indent for after ^^D in Insert mode or if flag
|
* "second_line_indent": indent for after ^^D in Insert mode or if flag
|
||||||
* OPENLINE_COM_LIST
|
* OPENLINE_COM_LIST
|
||||||
@@ -1498,9 +1500,11 @@ open_line(
|
|||||||
if (dir == FORWARD && did_ai)
|
if (dir == FORWARD && did_ai)
|
||||||
trunc_line = TRUE;
|
trunc_line = TRUE;
|
||||||
|
|
||||||
|
if ((flags & OPENLINE_FORCE_INDENT) && second_line_indent >= 0)
|
||||||
|
newindent = second_line_indent;
|
||||||
// If 'autoindent' and/or 'smartindent' is set, try to figure out what
|
// If 'autoindent' and/or 'smartindent' is set, try to figure out what
|
||||||
// indent to use for the new line.
|
// indent to use for the new line.
|
||||||
if (curbuf->b_p_ai || do_si)
|
else if (curbuf->b_p_ai || do_si)
|
||||||
{
|
{
|
||||||
// count white space on current line
|
// count white space on current line
|
||||||
#ifdef FEAT_VARTABS
|
#ifdef FEAT_VARTABS
|
||||||
|
@@ -4473,6 +4473,7 @@ ins_compl_expand_multiple(char_u *str)
|
|||||||
{
|
{
|
||||||
char_u *start = str;
|
char_u *start = str;
|
||||||
char_u *curr = str;
|
char_u *curr = str;
|
||||||
|
int base_indent = get_indent();
|
||||||
|
|
||||||
while (*curr != NUL)
|
while (*curr != NUL)
|
||||||
{
|
{
|
||||||
@@ -4483,7 +4484,7 @@ ins_compl_expand_multiple(char_u *str)
|
|||||||
ins_char_bytes(start, (int)(curr - start));
|
ins_char_bytes(start, (int)(curr - start));
|
||||||
|
|
||||||
// Handle newline
|
// Handle newline
|
||||||
open_line(FORWARD, OPENLINE_KEEPTRAIL, FALSE, NULL);
|
open_line(FORWARD, OPENLINE_KEEPTRAIL | OPENLINE_FORCE_INDENT, base_indent, NULL);
|
||||||
start = curr + 1;
|
start = curr + 1;
|
||||||
}
|
}
|
||||||
curr++;
|
curr++;
|
||||||
|
12
src/testdir/dumps/Test_pum_with_special_characters_09.dump
Normal file
12
src/testdir/dumps/Test_pum_with_special_characters_09.dump
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|l+0&#ffffff0|o|c|a|l| |a| |=| |f+0#ff404010&|u|n|c| |(|)| +0#0000000&@57
|
||||||
|
| +0#ff404010&@1| +0#0000000&@72
|
||||||
|
|e+0#ff404010&|n|d> +0#0000000&@71
|
||||||
|
|~+0#4040ff13&| | +0#0000001#e0e0e08|f|u|n|c|t|i|o|n| |(|)| @3| +0#4040ff13#ffffff0@56
|
||||||
|
|~| | +0#0000001#ffd7ff255|f|o@1|b|a|r| @8| +0#4040ff13#ffffff0@56
|
||||||
|
|~| | +0#0000001#ffd7ff255|你*&|好|^+&|@| @1|^|@|我*&|好| +&| +0#4040ff13#ffffff0@56
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|-+2#0000000&@1| |O|m|n|i| |c|o|m|p|l|e|t|i|o|n| |(|^|O|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |3| +0#0000000&@34
|
12
src/testdir/dumps/Test_pum_with_special_characters_10.dump
Normal file
12
src/testdir/dumps/Test_pum_with_special_characters_10.dump
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|l+0&#ffffff0|o|c|a|l| |a| |=| |f|u|n|c| |(|)| @57
|
||||||
|
@75
|
||||||
|
|e|n|d> @71
|
||||||
|
|~+0#4040ff13&| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|3|,|4| @10|A|l@1|
|
12
src/testdir/dumps/Test_pum_with_special_characters_11.dump
Normal file
12
src/testdir/dumps/Test_pum_with_special_characters_11.dump
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|l+0&#ffffff0|o|c|a|l| |a| |=| |f|u|n|c| |(|)| @57
|
||||||
|
@2|l|o|c|a|l| |b| |=| |f+0#ff404010&|u|n|c| |(|)| +0#0000000&@55
|
||||||
|
| +0#ff404010&@3| +0#0000000&@70
|
||||||
|
| +0#ff404010&@1|e|n|d> +0#0000000&@69
|
||||||
|
|e|n|d| | +0#0000001#e0e0e08|f|u|n|c|t|i|o|n| |(|)| @3| +0#0000000#ffffff0@54
|
||||||
|
|~+0#4040ff13&| @2| +0#0000001#ffd7ff255|f|o@1|b|a|r| @8| +0#4040ff13#ffffff0@54
|
||||||
|
|~| @2| +0#0000001#ffd7ff255|你*&|好|^+&|@| @1|^|@|我*&|好| +&| +0#4040ff13#ffffff0@54
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|-+2#0000000&@1| |O|m|n|i| |c|o|m|p|l|e|t|i|o|n| |(|^|O|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |3| +0#0000000&@34
|
12
src/testdir/dumps/Test_pum_with_special_characters_12.dump
Normal file
12
src/testdir/dumps/Test_pum_with_special_characters_12.dump
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|l+0&#ffffff0|o|c|a|l| |a| |=| |f|u|n|c| |(|)| @57
|
||||||
|
@2|l|o|c|a|l| |b| |=| |f|u|n|c| |(|)| @55
|
||||||
|
@75
|
||||||
|
@2|e|n|d> @69
|
||||||
|
|e|n|d| @71
|
||||||
|
|~+0#4040ff13&| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|4|,|5|-|6| @8|A|l@1|
|
@@ -1946,6 +1946,23 @@ func Test_pum_complete_with_special_characters()
|
|||||||
call VerifyScreenDump(buf, 'Test_pum_with_special_characters_08', {})
|
call VerifyScreenDump(buf, 'Test_pum_with_special_characters_08', {})
|
||||||
call term_sendkeys(buf, "\<C-E>\<Esc>")
|
call term_sendkeys(buf, "\<C-E>\<Esc>")
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":setlocal autoindent tabstop=2 shiftwidth=2\<CR>")
|
||||||
|
call term_sendkeys(buf, "Slocal a = \<C-X>\<C-O>")
|
||||||
|
call TermWait(buf, 50)
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_with_special_characters_09', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "\<C-Y>")
|
||||||
|
call TermWait(buf, 50)
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_with_special_characters_10', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "\<ESC>kAlocal b = \<C-X>\<C-O>")
|
||||||
|
call TermWait(buf, 50)
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_with_special_characters_11', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "\<C-Y>")
|
||||||
|
call TermWait(buf, 50)
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_with_special_characters_12', {})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -704,6 +704,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 */
|
||||||
|
/**/
|
||||||
|
1145,
|
||||||
/**/
|
/**/
|
||||||
1144,
|
1144,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1181,6 +1181,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
|
|||||||
#define OPENLINE_MARKFIX 0x08 // fix mark positions
|
#define OPENLINE_MARKFIX 0x08 // fix mark positions
|
||||||
#define OPENLINE_COM_LIST 0x10 // format comments with list/2nd line indent
|
#define OPENLINE_COM_LIST 0x10 // format comments with list/2nd line indent
|
||||||
#define OPENLINE_FORMAT 0x20 // formatting long comment
|
#define OPENLINE_FORMAT 0x20 // formatting long comment
|
||||||
|
#define OPENLINE_FORCE_INDENT 0x40 // use second_line_indent without indent logic
|
||||||
|
|
||||||
// There are five history tables:
|
// There are five history tables:
|
||||||
#define HIST_CMD 0 // colon commands
|
#define HIST_CMD 0 // colon commands
|
||||||
|
Reference in New Issue
Block a user