Merge remote-tracking branch 'krobelus/autocomplete-overrules-completers'

This commit is contained in:
Maxime Coste 2022-01-10 09:04:35 +11:00
commit 9acd4e62dc
6 changed files with 27 additions and 2 deletions

View File

@ -461,11 +461,11 @@ void InsertCompleter::select(int index, bool relative, Vector<Key>& 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();
}
@ -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())
{

View File

@ -107,6 +107,7 @@ private:
InsertCompletion m_completions;
Vector<BufferRange> m_inserted_ranges;
int m_current_candidate = -1;
bool m_enabled = true;
using CompleteFunc = InsertCompletion (const SelectionList& sels,
const OptionManager& options,

View File

@ -0,0 +1,3 @@

View File

@ -0,0 +1,3 @@
a2
./ui-in

View File

@ -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"

View File

@ -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": [ "<c-n><esc>" ] }'
# Implicit completion can be toggled.
ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "ji<c-o><c-n><esc>" ] }'
# Explicit completion still works.
ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "ji./ui-<c-x>f<c-n>" ] }'