Skip to content

Commit

Permalink
Triggers completion window while still allowing processing by VsVim
Browse files Browse the repository at this point in the history
Insert mode had a few issues. v2.8.0.8 fixed VsVim processing Insert mode keys but prevented the Intellisense window from appearing.

This fixes the 2.8.0.8 release by still allowing insert mode keys to be processed, but also triggering the Intellisense Window when needed.

Fixes #2832
Fixes #2844
Fixes #2807
  • Loading branch information
nosami committed Apr 22, 2021
1 parent 369641e commit ec63165
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Src/VimMac/VimKeyProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,32 @@ public override void KeyDown(KeyEventArgs e)
// Attempt to map the key information into a KeyInput value which can be processed
// by Vim. If this works and the key is processed then the input is considered
// to be handled

if (_keyUtil.TryConvertSpecialToKeyInput(e.Event, out KeyInput keyInput))
{
var bufferedKeyInputsWasEmpty = VimBuffer.BufferedKeyInputs.IsEmpty;

handled = TryProcess(keyInput);

if (handled
&& BufferedKeysWasEmptyAndIsEmpty()
&& oldMode == ModeKind.Insert
&& CharTriggersCompletion(keyInput.Char)
&& !_completionBroker.IsCompletionActive(VimBuffer.TextView))
{
// Because VsVim handled the key press for us in insert mode,
// we need to trigger the completion window to open.
_completionBroker.TriggerCompletion(VimBuffer.TextView);
}

bool BufferedKeysWasEmptyAndIsEmpty()
{
// We don't want the completion window to appear if we
// have something like `inoremap fd <esc>`
// and we just typed the first 'f' or the 'd'
return bufferedKeyInputsWasEmpty
&& VimBuffer.BufferedKeyInputs.IsEmpty;
}
}
}

Expand All @@ -94,6 +117,11 @@ public override void KeyDown(KeyEventArgs e)
e.Handled = handled;
}

private bool CharTriggersCompletion(char c)
{
return c == '_' || c == '.' || char.IsLetterOrDigit(c);
}

/// <summary>
/// Try and process the given KeyInput with the IVimBuffer. This is overridable by
/// derived classes in order for them to prevent any KeyInput from reaching the
Expand Down

0 comments on commit ec63165

Please sign in to comment.