Fix: close the view if cmp.enabled = false and the user types some text (#781)

A scenario where this lead to unintended behaviour previously was the following:

If cmp.enabled was configured such that it disabled cmp when in a comment,
and the user typed '--' in a lua file (this starts a comment), the cmp window
would not close if further text is typed on that line (although cmp should be disabled).
This commit is contained in:
Jonas Strittmatter
2022-02-11 05:36:54 +01:00
committed by GitHub
parent a7fea2ca9f
commit df05fe6ff4

View File

@@ -309,12 +309,18 @@ end)
autocmd.subscribe('TextChanged', function() autocmd.subscribe('TextChanged', function()
if config.enabled() then if config.enabled() then
cmp.core:on_change('TextChanged') cmp.core:on_change('TextChanged')
else
cmp.core:reset()
cmp.core.view:close()
end end
end) end)
autocmd.subscribe('CursorMoved', function() autocmd.subscribe('CursorMoved', function()
if config.enabled() then if config.enabled() then
cmp.core:on_moved() cmp.core:on_moved()
else
cmp.core:reset()
cmp.core.view:close()
end end
end) end)