summaryrefslogtreecommitdiffstats
path: root/runtime/indent
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-06-24 11:48:03 +0100
committerBram Moolenaar <Bram@vim.org>2022-06-24 11:48:03 +0100
commita57b553b432855667c9f26edfad95ccfdd24a6b7 (patch)
tree9f3fc55b3aecb5de3aefcdfcb1055d8acb87a9b9 /runtime/indent
parentabd56da30bae4a5c6c20b9363ccae12f7b126026 (diff)
Update runtime files
Diffstat (limited to 'runtime/indent')
-rw-r--r--runtime/indent/testdir/vim.in6
-rw-r--r--runtime/indent/testdir/vim.ok6
-rw-r--r--runtime/indent/vim.vim13
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 8579b3fb9f..8a2502a275 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