Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 51e6a43

Browse files
committed
Fix false positive multi-line string detection
Sometimes it seems that when `=`ing over a block, Vim will sometimes not re-highlight strings correctly until we have already ran `searchpairpos`. In this case, we implement a hacky workaround which detects the false-positive and recovers from it.
1 parent d177b3b commit 51e6a43

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

‎indent/clojure.vim

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,32 @@ function! s:GetClojureIndent()
9090
" Move cursor to the first column of the line we want to indent.
9191
call cursor(v:lnum, 1)
9292

93-
" Improve accuracy of string detection when a newline is entered.
9493
if empty(getline(v:lnum))
94+
" Improves the accuracy of string detection when a newline is
95+
" entered while in insert mode.
9596
let strline = v:lnum - 1
96-
let synname = s:GetSynIdName(strline, len(getline(strline)))
97+
let synname = s:GetSynIdName(strline, strlen(getline(strline)))
9798
else
9899
let synname = s:GetSynIdName(v:lnum, 1)
99100
endif
100101

101102
let s:best_match = ['top', [0, 0]]
102103

103104
if synname =~? 'string'
105+
" Sometimes, string highlighting does not kick in correctly,
106+
" until after this first "s:CheckPair" call, so we have to
107+
" detect and attempt an automatic correction.
104108
call s:CheckPair('str', '"', '"', function('<SID>NotStringDelimiter'))
109+
let new_synname = s:GetSynIdName(v:lnum, 1)
110+
if new_synname !=# synname
111+
echoerr 'Misdetected string! Retrying...'
112+
let s:best_match = ['top', [0, 0]]
113+
let synname = new_synname
114+
endif
115+
endif
116+
117+
if synname =~? 'string'
118+
" We already checked this above, so pass through this block.
105119
elseif synname =~? 'regex'
106120
call s:CheckPair('reg', '#\zs"', '"', function('<SID>NotRegexpDelimiter'))
107121
else

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /