diff options
-rw-r--r-- | runtime/indent/testdir/vim.in | 6 | ||||
-rw-r--r-- | runtime/indent/testdir/vim.ok | 6 | ||||
-rw-r--r-- | runtime/indent/vim.vim | 13 |
3 files changed, 22 insertions, 3 deletions
diff --git a/runtime/indent/testdir/vim.in b/runtime/indent/testdir/vim.in index 699e4c243d..873045bc2c 100644 --- a/runtime/indent/testdir/vim.in +++ b/runtime/indent/testdir/vim.in @@ -30,6 +30,12 @@ for x in [ eval 0 endfor +let t = [ +\ { +\ 'k': 'val', +\ }, +\ ] + " END_INDENT " START_INDENT diff --git a/runtime/indent/testdir/vim.ok b/runtime/indent/testdir/vim.ok index f597d97e80..8e70abe619 100644 --- a/runtime/indent/testdir/vim.ok +++ b/runtime/indent/testdir/vim.ok @@ -30,6 +30,12 @@ for x in [ eval 0 endfor +let t = [ + \ { + \ 'k': 'val', + \ }, + \ ] + " END_INDENT " START_INDENT diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim index cd2d4982d8..8076b2df07 100644 --- a/runtime/indent/vim.vim +++ b/runtime/indent/vim.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Vim script " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2022 Mar 01 +" Last Change: 2022 Jun 24 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -36,6 +36,14 @@ endfunc let s:lineContPat = '^\s*\(\\\|"\\ \)' function GetVimIndentIntern() + " If the current line has line continuation and the previous one too, use + " the same indent. This does not skip empty lines. + let cur_text = getline(v:lnum) + let cur_has_linecont = cur_text =~ s:lineContPat + if cur_has_linecont && v:lnum > 1 && getline(v:lnum - 1) =~ s:lineContPat + return indent(v:lnum - 1) + endif + " Find a non-blank line above the current line. let lnum = prevnonblank(v:lnum - 1) @@ -44,8 +52,7 @@ function GetVimIndentIntern() " If the current line doesn't start with '\' or '"\ ' and below a line that " starts with '\' or '"\ ', use the indent of the line above it. - let cur_text = getline(v:lnum) - if cur_text !~ s:lineContPat + if !cur_has_linecont while lnum > 0 && getline(lnum) =~ s:lineContPat let lnum = lnum - 1 endwhile |