Logical test simplification in detectindent

This commit is contained in:
Francesco Abbate 2021-04-06 08:27:35 +02:00
parent 3721ace099
commit 6e3cd41bd1
1 changed files with 3 additions and 2 deletions

View File

@ -105,13 +105,14 @@ local function update_cache(doc)
local type, size, score = detect_indent_stat(doc)
cache[doc] = { type = type, size = size, confirmed = (score >= adjust_threshold) }
doc.indent_info = cache[doc]
if score < adjust_threshold and Doc.on_text_change == doc_on_text_change then
if score < adjust_threshold and doc_on_text_change then
Doc.on_text_change = function(self, ...)
doc_on_text_change(self, ...)
update_cache(self)
end
elseif score >= adjust_threshold and Doc.on_text_change ~= doc_on_text_change then
elseif score >= adjust_threshold and doc_on_text_change then
Doc.on_text_change = doc_on_text_change
doc_on_text_change = nil
end
end