vim-patch:9.1.1145: multi-line completion has wrong indentation for last line (#32625)

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: vim/vim#16614

5090a1fecb
This commit is contained in:
glepnir
2025-02-25 14:30:21 +08:00
committed by GitHub
parent 095c0876c2
commit c9a2b16c48
5 changed files with 78 additions and 10 deletions

View File

@@ -1071,6 +1071,7 @@ bool copy_indent(int size, char *src)
/// 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
@@ -1162,9 +1163,11 @@ bool open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
trunc_line = true;
}
// 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) {
if ((flags & OPENLINE_FORCE_INDENT)) {
newindent = second_line_indent;
} else if (curbuf->b_p_ai || do_si) {
// If 'autoindent' and/or 'smartindent' is set, try to figure out what
// indent to use for the new line.
// count white space on current line
newindent = indent_size_ts(saved_line, curbuf->b_p_ts, curbuf->b_p_vts_array);
if (newindent == 0 && !(flags & OPENLINE_COM_LIST)) {