diff --git a/src/insert_completer.cc b/src/insert_completer.cc index 54792052..f32b35ca 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -461,12 +461,12 @@ void InsertCompleter::select(int index, bool relative, Vector& keystrokes) void InsertCompleter::update(bool allow_implicit) { + m_enabled = allow_implicit or m_explicit_completer; if (m_explicit_completer and try_complete(m_explicit_completer)) return; reset(); - if (allow_implicit) - setup_ifn(); + setup_ifn(); } auto& get_first(BufferRange& range) { return range.begin; } @@ -500,6 +500,8 @@ void InsertCompleter::reset() bool InsertCompleter::setup_ifn() { + if (!m_enabled) + return false; using namespace std::placeholders; if (not m_completions.is_valid()) { diff --git a/src/insert_completer.hh b/src/insert_completer.hh index b3c7480d..1d68be86 100644 --- a/src/insert_completer.hh +++ b/src/insert_completer.hh @@ -107,6 +107,7 @@ private: InsertCompletion m_completions; Vector m_inserted_ranges; int m_current_candidate = -1; + bool m_enabled = true; using CompleteFunc = InsertCompletion (const SelectionList& sels, const OptionManager& options, diff --git a/test/regression/0-autocomplete-overrules-completers/in b/test/regression/0-autocomplete-overrules-completers/in new file mode 100644 index 00000000..b28b04f6 --- /dev/null +++ b/test/regression/0-autocomplete-overrules-completers/in @@ -0,0 +1,3 @@ + + + diff --git a/test/regression/0-autocomplete-overrules-completers/out b/test/regression/0-autocomplete-overrules-completers/out new file mode 100644 index 00000000..ee504471 --- /dev/null +++ b/test/regression/0-autocomplete-overrules-completers/out @@ -0,0 +1,3 @@ + +a2 +./ui-in diff --git a/test/regression/0-autocomplete-overrules-completers/rc b/test/regression/0-autocomplete-overrules-completers/rc new file mode 100644 index 00000000..a3c831f3 --- /dev/null +++ b/test/regression/0-autocomplete-overrules-completers/rc @@ -0,0 +1,6 @@ +set-option global autocomplete prompt +declare-option -hidden completions line1_completions +declare-option -hidden completions line2_completions +set-option global completers option=line1_completions option=line2_completions +set-option global line1_completions "1.1+0@%val(timestamp)" "a1||a1" +set-option global line2_completions "2.1+0@%val(timestamp)" "a2||a2" diff --git a/test/regression/0-autocomplete-overrules-completers/script b/test/regression/0-autocomplete-overrules-completers/script new file mode 100644 index 00000000..5a4d2aaf --- /dev/null +++ b/test/regression/0-autocomplete-overrules-completers/script @@ -0,0 +1,10 @@ +ui_out -ignore 4 +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "i" ] }' +sleep .2 # trigger insert completion auto update +# Implicit completion is disabled via autocomplete. +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "" ] }' +# Implicit completion can be toggled. +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "ji" ] }' +# Explicit completion still works. +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "ji./ui-f" ] }' +