Skip to content

Commit 84d5e0c

Browse files
committed
Merge branch 'no-cursor-move-during-indentexpr'
While an indentexpr is allowed to move the cursor while calculating a line's indent, doing so makes GetClojureIndent() unusable as a library function. Paredit.vim, for instance, makes use of this function. Closes #49 * no-cursor-move-during-indentexpr: Eliminate cursor side-effect in GetClojureIndent(). Fix GetClojureIndent() undesireable cursor move.
2 parents f52c5d0 + fe60b97 commit 84d5e0c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

indent/clojure.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ if exists("*searchpairpos")
306306

307307
function! GetClojureIndent()
308308
let lnum = line('.')
309+
let cnum = col('.')
309310
let [opening_lnum, indent] = s:clojure_indent_pos()
310311

311312
" Account for multibyte characters
@@ -315,6 +316,7 @@ if exists("*searchpairpos")
315316

316317
" Return if there are no previous lines to inherit from
317318
if opening_lnum < 1 || opening_lnum >= lnum - 1
319+
call cursor(lnum, cnum)
318320
return indent
319321
endif
320322

@@ -349,11 +351,13 @@ if exists("*searchpairpos")
349351
" Check if this is part of a multiline string
350352
call cursor(lnum, 1)
351353
if s:syn_id_name() !~? '\vstring|regex'
354+
call cursor(lnum, cnum)
352355
return indent(lnum)
353356
endif
354357
endif
355358
endwhile
356359

360+
call cursor(lnum, cnum)
357361
return indent
358362
endfunction
359363

0 commit comments

Comments
 (0)