From 6422a5a479905bf32abe7a322d1c0b0a75d4aa8c Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 23 Oct 2020 02:36:02 +0200 Subject: Count all multiplies for given indent, fixes #592 --- ftdetect/polyglot.vim | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'ftdetect') diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 938aac73..2ebfec95 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -2643,10 +2643,20 @@ if !has_key(s:disabled_packages, 'autoindent') func! s:get_shiftwidth(indents) abort let shiftwidth = 0 let max_count = 0 + let final_counts = {} for [indent, indent_count] in items(a:indents) - if indent_count > max_count + let indent_count *= 1.5 + for [indent2, indent2_count] in items(a:indents) + if indent2 > indent && indent2 % indent == 0 + let indent_count += indent2_count + endif + endfor + let final_counts[indent] = indent_count + endfor + for [indent, final_count] in items(final_counts) + if final_count > max_count let shiftwidth = indent - let max_count = indent_count + let max_count = final_count endif endfor return shiftwidth -- cgit v1.2.3