summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-07-14 23:48:48 -0700
committerOri Bernstein <ori@eigenstate.org>2015-07-14 23:48:48 -0700
commit7875472935a9a130442eaef382db8167921450ae (patch)
treef471a138efcc5b03cbd45f6c6d8bcd6cef8e601d /support
parent5d986e613a56c158f3cdab000a12a75da2f6b28b (diff)
downloadmc-7875472935a9a130442eaef382db8167921450ae.tar.gz
Clamp indentation delta.
We don't want to indent/outdent by more than one level at a time.
Diffstat (limited to 'support')
-rw-r--r--support/vim/indent/myr.vim13
1 files changed, 12 insertions, 1 deletions
diff --git a/support/vim/indent/myr.vim b/support/vim/indent/myr.vim
index d64489f..8fc7e6a 100644
--- a/support/vim/indent/myr.vim
+++ b/support/vim/indent/myr.vim
@@ -45,6 +45,15 @@ function! s:LineMatch(line, pats)
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 @@ function! GetMyrIndent(ln)
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