diff --git a/autoload/indent_guides.vim b/autoload/indent_guides.vim index aea655f..0c0d1b4 100644 --- a/autoload/indent_guides.vim +++ b/autoload/indent_guides.vim @@ -41,8 +41,8 @@ function! indent_guides#enable() " will automagically figure out whether to use tabs or spaces for l:level in range(s:start_level, s:indent_levels) let l:group = 'IndentGuides' . ((l:level % 2 == 0) ? 'Even' : 'Odd') - let l:pattern = '^\s\{' . (l:level * s:indent_size - s:indent_size) . '\}\zs' - let l:pattern .= '\s\{' . s:guide_size . '\}' + let l:pattern = '^\s*\%' . ((l:level - 1) * s:indent_size + 1) . 'v\zs' + let l:pattern .= '\s*\%' . (((l:level - 1) * s:indent_size + 1) + s:guide_size) . 'v' let l:pattern .= '\ze' " define the higlight pattern and add to list @@ -207,12 +207,17 @@ endfunction " function! indent_guides#calculate_guide_size() let l:guide_size = g:indent_guides_guide_size - let l:indent_size = indent_guides#get_indent_size() - if l:indent_size > 1 && l:guide_size >= 1 - let l:guide_size = (l:guide_size > s:indent_size) ? s:indent_size : l:guide_size - else + if &expandtab == 0 && &tabstop == s:indent_size let l:guide_size = s:indent_size + else + if s:indent_size > 1 && l:guide_size >= 1 + if l:guide_size > s:indent_size + let l:guide_size = s:indent_size + end + else + let l:guide_size = s:indent_size + endif endif return l:guide_size @@ -223,7 +228,7 @@ endfunction " being used. " function! indent_guides#get_indent_size() - return (&l:expandtab == 1) ? &l:shiftwidth : 1 + return &l:shiftwidth endfunction " diff --git a/test-files/test-ts2sw2et.txt b/test-files/test-ts2sw2et.txt index c0660fb..f480955 100644 --- a/test-files/test-ts2sw2et.txt +++ b/test-files/test-ts2sw2et.txt @@ -1,4 +1,4 @@ -vim:tw=78:ts=2:sw=2:et +vim:tw=78:ts=2:sw=2:et:nolist test test diff --git a/test-files/test-ts2sw2noet.txt b/test-files/test-ts2sw2noet.txt index f0d1c8f..35e8943 100644 --- a/test-files/test-ts2sw2noet.txt +++ b/test-files/test-ts2sw2noet.txt @@ -1,4 +1,4 @@ -vim:tw=78:ts=2:sw=2:noet +vim:tw=78:ts=2:sw=2:noet:nolist test test diff --git a/test-files/test-ts4sw4et.txt b/test-files/test-ts4sw4et.txt index f3ba85b..f1e99bf 100644 --- a/test-files/test-ts4sw4et.txt +++ b/test-files/test-ts4sw4et.txt @@ -1,4 +1,4 @@ -vim:tw=78:ts=4:sw=4:et +vim:tw=78:ts=4:sw=4:et:nolist test test diff --git a/test-files/test-ts4sw4noet.txt b/test-files/test-ts4sw4noet.txt index e38791e..8a72d94 100644 --- a/test-files/test-ts4sw4noet.txt +++ b/test-files/test-ts4sw4noet.txt @@ -1,4 +1,4 @@ -vim:tw=78:ts=4:sw=4:noet +vim:tw=78:ts=4:sw=4:noet:nolist test test diff --git a/test-files/test-ts8sw2noet.txt b/test-files/test-ts8sw2noet.txt new file mode 100644 index 0000000..0002913 --- /dev/null +++ b/test-files/test-ts8sw2noet.txt @@ -0,0 +1,24 @@ +vim:tw=78:ts=8:sw=2:noet:nolist + +test + test + test + test + test + test + test + test + test + test + test + test + test + test + test + test + test + test + test + test + test + test diff --git a/test-files/test-ts8sw8et.txt b/test-files/test-ts8sw8et.txt index 0550dbe..247802e 100644 --- a/test-files/test-ts8sw8et.txt +++ b/test-files/test-ts8sw8et.txt @@ -1,4 +1,4 @@ -vim:tw=78:ts=8:sw=8:et +vim:tw=78:ts=8:sw=8:et:nolist test test diff --git a/test-files/test-ts8sw8noet.txt b/test-files/test-ts8sw8noet.txt index 7b31d5b..1ee2a19 100644 --- a/test-files/test-ts8sw8noet.txt +++ b/test-files/test-ts8sw8noet.txt @@ -1,4 +1,4 @@ -vim:tw=78:ts=8:sw=8:noet +vim:tw=78:ts=8:sw=8:noet:nolist test test