ref: 7875472935a9a130442eaef382db8167921450ae
parent: 5d986e613a56c158f3cdab000a12a75da2f6b28b
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jul 14 19:48:48 EDT 2015
Clamp indentation delta. We don't want to indent/outdent by more than one level at a time.
--- a/support/vim/indent/myr.vim
+++ b/support/vim/indent/myr.vim
@@ -45,6 +45,15 @@
return 0
endfunction
+function s:Clamp(val, lo, hi)
+ if a:val < a:lo
+ returnn a:lo
+ elseif a:val > a:hi
+ return a:hi
+ endif
+ return a:val
+endfunction
+
function! GetMyrIndent(ln)
let ln = a:ln
@@ -88,7 +97,9 @@
let n_out = n_out + 1
endif
- let ind = ind + (n_in - n_out) * &tabstop
+ let delta = s:Clamp(n_in - n_out, -1, 1)
+ echo "n_in: " n_in " n_out: " n_out " delta: " delta
+ let ind = ind + delta * &tabstop
endif
return ind
endfunction