Meikel Brandmeyer committed 0f87447

Fix slow-down of indentation in big files (reported by Brandon Bloom)

  • Participants
  • Parent commits 4d3717b

Comments (0)

Files changed (3)

File vim/autoload/vimclojure.vim

 	let vimclojure#SetupKeyMap = 1
+if !exists("g:vimclojure#SearchThreshold")
+	let vimclojure#SearchThreshold = 100
 function! vimclojure#ReportError(msg)
 	if g:vimclojure#UseErrorBuffer
 		let buf = g:vimclojure#ResultBuffer.New()

File vim/doc/clojure.txt

 This option is disabled by default.
+To be able to properly indent a given line there is some searching
+necessary to determine the surroundings of the cursor. In big files
+this my result in a slow down when entering a new line. So there is
+an option to basically limit the horizon which is searched for the
+indentation to synchronise. By default this is 100 lines backwards in
+the file. However you may specify whatever value works best for you.
+Higher values mean more searching.
+        let vimclojure#SearchThreshold = 100
 Preview Window

File vim/indent/clojure.vim

 function! s:MatchPairs(open, close, stopat)
 	" Stop only on vector and map [ resp. {. Ignore the ones in strings and
 	" comments.
+	if a:stopat == 0
+		let stopat = max([line(".") - g:vimclojure#SearchThreshold, 0])
+	else
+		let stopat = a:stopat
+	endif
 	return searchpairpos(a:open, '', a:close, 'bWn',
 				\ 'vimclojure#util#SynIdName() !~ "clojureParen\\d"',
-				\ a:stopat)
+				\ stopat)
 function! ClojureCheckForStringWorker() dict