Meikel  Brandmeyer avatar Meikel Brandmeyer committed 0f87447

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

Comments (0)

Files changed (3)


 	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()


 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


 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.