From a4a9a9492361b903cfcf85741eb11ffca3989761 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Wed, 9 Dec 2015 17:54:47 +0100 Subject: [PATCH] Add `match.discard()` Solves commit bbdfa761 in a cleaner way. --- documentation/api.md | 4 ++++ extension/lib/modes.coffee | 2 +- extension/lib/vimfx.coffee | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/documentation/api.md b/documentation/api.md index 9ee96da..7675472 100644 --- a/documentation/api.md +++ b/documentation/api.md @@ -501,6 +501,10 @@ A `match` object has the following properties: shortcut key tree. This is `true` unless the match is part of the tail of a multi-key shortcut. +- discard(): `Function`. Discards keys pressed so far: If `type` is `'partial'` + or `'count'`. For example, if you have typed `12g`, run `match.discard()` and + then press `$`, the `$` command will be run instead of `12g$`. + ### Vim object There is one `vim` object per tab. diff --git a/extension/lib/modes.coffee b/extension/lib/modes.coffee index 52b88de..6a59a9f 100644 --- a/extension/lib/modes.coffee +++ b/extension/lib/modes.coffee @@ -66,7 +66,7 @@ mode('normal', { autoInsertMode = (match.focus != null) if match.type == 'none' or (autoInsertMode and not match.specialKeys['']) - vim._parent.reset('normal') + match.discard() if storage.returnTo vim.enterMode(storage.returnTo) storage.returnTo = null diff --git a/extension/lib/vimfx.coffee b/extension/lib/vimfx.coffee index 529f8a0..88056d0 100644 --- a/extension/lib/vimfx.coffee +++ b/extension/lib/vimfx.coffee @@ -112,6 +112,7 @@ class VimFx extends utils.EventEmitter @reset(mode) if type == 'full' return { type, focus, command, count, specialKeys, keyStr, unmodifiedKey, toplevel + discard: @reset.bind(this, mode) } adjustFocusType: (event, vim, focusType, keyStr) -> -- 2.39.3