Skip to content

Commit 4a3cab7

Browse files
committed
Fix string detection when entering a newline while in insert mode
1 parent 2627e1c commit 4a3cab7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

indent/clojure.vim

+9-3
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,23 @@ endfunction
6565

6666
function! s:GetClojureIndent()
6767
" Move cursor to the first column of the line we want to indent.
68-
call cursor(v:lnum, 0)
68+
call cursor(v:lnum, 1)
6969

7070
let s:best_match = ['top', [0, 0]]
7171

7272
let IgnoredRegionFn = function('<SID>IgnoredRegion')
73-
7473
call s:CheckPair('lst', '(', ')', IgnoredRegionFn)
7574
call s:CheckPair('map', '{', '}', IgnoredRegionFn)
7675
call s:CheckPair('vec', '\[', '\]', IgnoredRegionFn)
7776

78-
let synname = s:GetSynIdName(v:lnum, col('.'))
77+
" Improve accuracy of string detection when a newline is entered.
78+
if empty(getline(v:lnum))
79+
let strline = v:lnum - 1
80+
let synname = s:GetSynIdName(strline, len(getline(strline)))
81+
else
82+
let synname = s:GetSynIdName(v:lnum, 1)
83+
endif
84+
7985
if synname =~? 'string'
8086
call s:CheckPair('str', '"', '"', function('<SID>NotStringDelimiter'))
8187
elseif synname =~? 'regex'

0 commit comments

Comments
 (0)