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>
diff --git a/src/change.c b/src/change.c
index 294adf7..a3329bd 100644
--- a/src/change.c
+++ b/src/change.c
@@ -1385,6 +1385,8 @@
* 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 @@
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