summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2020-10-23 02:36:02 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2020-10-23 02:36:02 +0200
commit6422a5a479905bf32abe7a322d1c0b0a75d4aa8c (patch)
tree8c6a83e4c5f4d41c5c99b5ac8066036a55ebf156
parent113f9b8949643f7e02c29051ad2148c3265b8131 (diff)
downloadvim-polyglot-6422a5a479905bf32abe7a322d1c0b0a75d4aa8c.tar.gz
vim-polyglot-6422a5a479905bf32abe7a322d1c0b0a75d4aa8c.zip
Count all multiplies for given indent, fixes #592
-rw-r--r--ftdetect/polyglot.vim14
1 files changed, 12 insertions, 2 deletions
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