Count all multiplies for given indent, fixes #592

This commit is contained in:
Adam Stankiewicz
2020-10-23 02:36:02 +02:00
parent 113f9b8949
commit 6422a5a479

View File

@@ -2643,10 +2643,20 @@ if !has_key(s:disabled_packages, 'autoindent')
func! s:get_shiftwidth(indents) abort func! s:get_shiftwidth(indents) abort
let shiftwidth = 0 let shiftwidth = 0
let max_count = 0 let max_count = 0
let final_counts = {}
for [indent, indent_count] in items(a:indents) 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 shiftwidth = indent
let max_count = indent_count let max_count = final_count
endif endif
endfor endfor
return shiftwidth return shiftwidth