1
0
forked from aniani/vim

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:
glepnir
2025-02-24 19:10:37 +01:00
committed by Christian Brabandt
parent 5b97947bbd
commit 5090a1fecb
9 changed files with 81 additions and 8 deletions

View File

@@ -1385,6 +1385,8 @@ del_bytes(
* OPENLINE_KEEPTRAIL keep trailing spaces
* OPENLINE_MARKFIX adjust mark positions after the line break
* 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
* OPENLINE_COM_LIST
@@ -1498,9 +1500,11 @@ open_line(
if (dir == FORWARD && did_ai)
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
// 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
#ifdef FEAT_VARTABS