VSCodeVim / VSCodeVim/Vim

Big refactor of action handling

Open
#4,698 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Here's a tentative game plan. The goal of this is to reduce the inconsistency and weirdness in the boundary between ModeHandler and actions, particularly when it comes to multiple cursors.

  1. Stop returning VimState from actions. It's not immutable, and it's clear that it's being altered. IMO this is just noise.
  2. Stop passing Position to actions. This should always be vimState.cursorStopPosition, and it's clearer if this is used directly.
  3. Unify exec, execAction, etc. execCount, unless I'm mistaken, should be in ModeHandler.
  4. Rename Range to Cursor and add extra data to it (desiredColumn, etc.). Some usages of Range actually do just refer to a range - these can use vscode.Range.

The hope is that after this, actions will have an exec method that can just be called with each cursor, and nobody will really have to worry about the details of what's going on behind the scenes.

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 ModeHandler, actions, exec/execAction, execCount, Position, and Range usages to understand the current action boundary and multiple-cursor flow. The refactor is done when actions expose a unified exec method per cursor, no longer receive redundant state or position data, and Range is separated from cursor-specific data as described in the plan.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.