diff options
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | autoload/detect_indent.vim | 23 |
2 files changed, 12 insertions, 13 deletions
@@ -1 +1 @@ -0.1.3 +0.1.4 diff --git a/autoload/detect_indent.vim b/autoload/detect_indent.vim index ab3f485..bae5f7c 100644 --- a/autoload/detect_indent.vim +++ b/autoload/detect_indent.vim @@ -61,25 +61,20 @@ function! detect_indent#() abort endfor - " If the value for 'expandtab' as determined by the user's configuration - " matches the expected dominance of space-indented lines over tab-indented - " lines, we're already using the right setting, and we stop here - " - if &expandtab == (spaces['total'] >= tabs) - return - endif - - " If 'expandtab' is set, we need to unset it and switch to pure tab + " If 'expandtab' is set, but more lines in the existing buffer have tab + " indents than space indents, we need to unset it and switch to pure tab " indenting; that's straightforward, we just need to make sure 'shiftwidth' " matches 'tabstop', and that 'softtabstop' is off. " - if &expandtab + if &expandtab && tabs > spaces['total'] setlocal noexpandtab softtabstop=0 let &l:shiftwidth = &tabstop - " If 'expandtab' is not set, we need to set it, and guess an appropriate + " If 'expandtab' is unset, but more lines in the existing buffer have space + " indents than tab indents, we need to set it, and guess an appropriate " 'shiftwidth'. - else + " + elseif !&expandtab && tabs < spaces['total'] setlocal expandtab " Iterate through the keys of the histogram from smallest to largest. @@ -102,6 +97,10 @@ function! detect_indent#() abort let &l:shiftwidth = shiftwidth let &l:softtabstop = shiftwidth + " If the 'expandtab' setting looks like it was already accurate to the + " buffer, stop here + else + return endif " Since we just messed with indent settings, stack up a command to revert |