Skip to content

Commit 62fa6df

Browse files
committed
Avoid the use of :normal in the indentexpr
Docs state that the indentexpr must not contain side effects, but that moving the cursor is okay because it will be reset. However, a closer look reveals that :normal commands for moving the cursor have side effects beyond just moving the cursor and thus do not behave properly. The Vim documentation should be changed to make this more clear, but we can do our part now.
1 parent 1b47218 commit 62fa6df

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

indent/clojure.vim

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ if exists("*searchpairpos")
256256
endif
257257

258258
" In case after the paren is a whitespace, we search for the next word.
259-
normal! l
259+
call cursor(0, col('.') + 1)
260260
if s:CurrentChar() == ' '
261-
normal! w
261+
call search('\v\S', 'W')
262262
endif
263263

264264
" If we moved to another line, there is no word after the (. We
@@ -290,12 +290,13 @@ if exists("*searchpairpos")
290290
return paren[1] + &shiftwidth - 1
291291
endif
292292

293-
normal! W
293+
call search('\v\s|\n', 'cW')
294+
call search('\v\S', 'W')
294295
if paren[0] < line(".")
295296
return paren[1] + &shiftwidth - 1
296297
endif
297298

298-
normal! ge
299+
call search('\v\S', 'bW')
299300
return virtcol(".") + 1
300301
endfunction
301302

0 commit comments

Comments
 (0)