]> git.ipfire.org Git - thirdparty/vim.git/commit
runtime(yaml): update YAML indentation for mapping keys inside list items
authorCezar Dimoiu <cezar.dimoiu@keysight.com>
Thu, 8 Jan 2026 20:05:07 +0000 (20:05 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 8 Jan 2026 20:07:18 +0000 (20:07 +0000)
commit9179ddc0608813e9dd7cf9ba856d61669d6f0e3a
tree3c2c18eb352ec45ff73fe379486193a4c05577fc
parent4895ae8c0cd144c98cfb05e0162c2caac8f63c4c
runtime(yaml): update YAML indentation for mapping keys inside list items

When a list item contains a mapping key (e.g., '- element1:'), the
content under that key was incorrectly indented. The indent function
was not accounting for the '- ' prefix when calculating indentation
for nested content.

Example that now works correctly:
  list:
    - element1:
        foo: bar  # Now correctly at indent 6, not 4

The fix adds special handling in two places:
1. When previous line ends with ':' and starts with '- '
2. When looking up previous mapping key that is a list item

Fixes indentation to account for the 2-character '- ' prefix.

fixes:  #18943
closes: #19133

Signed-off-by: Cezar Dimoiu <cezar.dimoiu@keysight.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/indent/testdir/yaml.in
runtime/indent/testdir/yaml.ok
runtime/indent/yaml.vim