From df05fe6ff491e7be6e71ade6200dfbc7e44311f8 Mon Sep 17 00:00:00 2001 From: Jonas Strittmatter <40792180+smjonas@users.noreply.github.com> Date: Fri, 11 Feb 2022 05:36:54 +0100 Subject: [PATCH] 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). --- lua/cmp/init.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/cmp/init.lua b/lua/cmp/init.lua index dc8754e..99432bd 100644 --- a/lua/cmp/init.lua +++ b/lua/cmp/init.lua @@ -309,12 +309,18 @@ end) autocmd.subscribe('TextChanged', function() if config.enabled() then cmp.core:on_change('TextChanged') + else + cmp.core:reset() + cmp.core.view:close() end end) autocmd.subscribe('CursorMoved', function() if config.enabled() then cmp.core:on_moved() + else + cmp.core:reset() + cmp.core.view:close() end end)