Skip to content

Commit 484c281

Browse files
committed
Do not take indent of subsequent lines of a multiline string
1 parent c06750a commit 484c281

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
(foo bar [✖])
1+
(foo bar
2+
"This string has unpaired brackets
3+
["
4+
α
5+
[β])
26

37
;; vim:ft=clojure:

clj/dev-resources/test-inherit-indent.out

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
(foo bar [
1+
(foo bar
2+
"This string has unpaired brackets
3+
["
4+
a
5+
6+
[
27
a
38
b
49

clj/test/vim_clojure_static/indent_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
(test-indent "is inherited from previous element"
77
:in "test-inherit-indent.in"
88
:out "test-inherit-indent.out"
9-
:keys "/\\<Esc>s\\<CR>\\<C-H>\\<C-H>\\<C-H>\\<C-H>a\\<CR>b\\<CR>\\<CR>c\\<Esc>"))
9+
:keys "/α\\<CR>s\\<Esc>Oa\\<Esc>/β\\<CR>s\\<CR>\\<C-H>\\<C-H>a\\<CR>b\\<CR>\\<CR>c\\<Esc>"))

indent/clojure.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,11 @@ if exists("*searchpairpos")
346346
endwhile
347347

348348
if bracket_count == 0
349-
return indent(lnum)
349+
" Check if this is part of a multiline string
350+
call cursor(lnum, 0)
351+
if s:syn_id_name() !~? '\vstring|regex'
352+
return indent(lnum)
353+
endif
350354
endif
351355
endwhile
352356

0 commit comments

Comments
 (0)