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 d978de5

Browse files
committed
Fix indentexpr cursor restoration and add a test case
1 parent 84d5e0c commit d978de5

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(doseq [x (range 10) y (range 10)]
2+
(println α)
3+
(println β))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(doseq [x (range 10) y (range 10)]
2+
(println x)
3+
(println y))

‎clj/test/vim_clojure_static/indent_test.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@
1717
:in "test-inherit-indent.in"
1818
:out "test-inherit-indent.out"
1919
:keys "\\<CR>s\\<C-O>Oa\\<Esc>/β\\<CR>s\\<CR>\\<CR>\\<C-H>\\<C-H>\\<C-H>\\<C-H>\\<C-H>\\<C-H>\\<C-H>b\\<CR>c\\<CR>\\<CR>d\\<Esc>"))
20+
21+
(deftest test-side-effects-in-indentexpr
22+
(test-indent "GetClojureIndent does not move cursor"
23+
:in "test-side-effects-in-indentexpr.in"
24+
:out "test-side-effects-in-indentexpr.out"
25+
:keys "\\<CR>:call GetClojureIndent()\\<CR>rxj:call GetClojureIndent()\\<CR>ry"))

‎indent/clojure.vim

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

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

312313
" Account for multibyte characters
@@ -316,7 +317,7 @@ if exists("*searchpairpos")
316317

317318
" Return if there are no previous lines to inherit from
318319
if opening_lnum < 1 || opening_lnum >= lnum - 1
319-
call cursor(lnum, cnum)
320+
call cursor(orig_lnum, orig_col)
320321
return indent
321322
endif
322323

@@ -351,13 +352,13 @@ if exists("*searchpairpos")
351352
" Check if this is part of a multiline string
352353
call cursor(lnum, 1)
353354
if s:syn_id_name() !~? '\vstring|regex'
354-
call cursor(lnum, cnum)
355+
call cursor(orig_lnum, orig_col)
355356
return indent(lnum)
356357
endif
357358
endif
358359
endwhile
359360

360-
call cursor(lnum, cnum)
361+
call cursor(orig_lnum, orig_col)
361362
return indent
362363
endfunction
363364

0 commit comments

Comments
(0)

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