VSCodeVim / VSCodeVim/Vim

Pass count to the command called by remapper

Open
#7,858 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

Is your feature request related to a problem? Please describe.
This is to solve https://github.com/VSpaceCode/VSpaceCode/issues/278.

When a user used vim.normalModeKeyBindingsNonRecursive to remap to a command,

  1. there's no way for an extension to integrate with the count information
  2. The count still persist after the command executed

For example:

"vim.normalModeKeyBindingsNonRecursive": [
	{
		"before": ["<space>"],
		"commands": ["vspacecode.space"],
	},
]

VSpaceCode has no way to get the count when a user press 2 <space>, and after the command has been executed the 2 still exists.

Describe the solution you'd like
Is there any way we can pass the count (or more general the vim state) when we call the command?

For example:

"vim.normalModeKeyBindingsNonRecursive": [
	{
		"before": ["<space>"],
		"commands": [
			{"command": "whichkey.triggerKey", args: "$count"}
		],
	},
]

The remapper will inspect the args and replace $count with the count. This can also support other variables like $registers.

Describe alternatives you've considered

"vim.normalModeKeyBindingsNonRecursive": [
	{
		"before": ["<space>"],
		"commands": [
			{"commandWithVimState": "whichkey.triggerKey"}
		],
	},
]

When space is entered, it will pass vim state as parameter when executing command the vscode.commands.executeCommand(commandString, vimState).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the remapper executes commands from normalModeKeyBindingsNonRecursive and how count state is retained after execution. Compare the proposed args substitution with passing the full Vim state, then verify that a remapped command can receive the count and that the count no longer persists.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.