Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 8, 2025

Problem

Users who map cursorMove commands to keyboard shortcuts with large step values (e.g., PageUp/PageDown moving 20 lines at a time) were finding that these movements were being added to navigation history. This caused workbench.action.navigateBack and workbench.action.navigateForward commands to replay all these intermediate cursor positions, making navigation history essentially unusable for users with such keybindings.

For example:

{
  "key": "pagedown",
  "when": "textInputFocus",
  "command": "cursorMove",
  "args": {
    "to": "down",
    "by": "line",
    "value": 20
  }
}

With this keybinding, pressing PageDown a few times would clutter the navigation history with multiple 20-line jumps, and subsequent "Go Back" commands would step through each of these positions instead of jumping to meaningful navigation points.

Solution

This PR adds an optional noHistory boolean argument to the cursorMove command. When set to true, cursor movements are not added to navigation history.

The implementation works by using TextEditorSelectionSource.PROGRAMMATIC as the source when noHistory is true. This source type is already recognized throughout VS Code as indicating programmatic cursor movements (e.g., from API calls or automatic selection restoration), which are intentionally excluded from navigation history.

Usage

{
  "key": "pagedown",
  "when": "textInputFocus",
  "command": "cursorMove",
  "args": {
    "to": "down",
    "by": "line",
    "value": 20,
    "noHistory": true
  }
}

Changes

  • Added noHistory?: boolean to CursorMove.RawArguments interface
  • Updated argument validation and command metadata to include the new argument
  • Modified _runCursorMove() to use TextEditorSelectionSource.PROGRAMMATIC when noHistory is true
  • Updated schema and documentation to describe the new argument

Backward Compatibility

The noHistory argument is optional and defaults to false, so existing keybindings and code that don't specify it will continue to work exactly as before.

Fixes #<issue_number>

Original prompt

This section details on the original issue you should resolve

<issue_title>Add arg to cursorMove command to not add the movement to navigation history</issue_title>
<issue_description>I map this to my page up/down keys to speed up navigating by lines:

{
	"key": "pagedown",
	"when": "textInputFocus",
	"command": "cursorMove",
	"args": {
		"to": "down",
		"by": "line",
		"value": 20
	}
},

The problem is that cursorMove command adds to navigation history, which means my other shortcuts using commands workbench.action.navigateBack and workbench.action.navigateForward now start replaying these 20 line steps, which I never want.

It'd be great if cursorMove had a "history": false argument.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #256837

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: hediet <2931520+hediet@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Add 'history' argument to cursorMove command Add noHistory argument to cursorMove command to skip navigation history Oct 8, 2025
@Copilot Copilot AI requested a review from hediet October 8, 2025 15:23
Copilot finished work on behalf of hediet October 8, 2025 15:23
@hediet hediet marked this pull request as ready for review October 8, 2025 16:41
@Copilot Copilot AI review requested due to automatic review settings October 8, 2025 16:41
@hediet hediet added this to the October 2025 milestone Oct 8, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a noHistory argument to the cursorMove command to allow users to disable navigation history tracking for cursor movements. This is particularly useful for users who map cursorMove commands with large step values to keyboard shortcuts, preventing these movements from cluttering navigation history.

  • Added optional noHistory boolean parameter to cursorMove command arguments
  • Updated command validation, schema, and documentation to include the new parameter
  • Modified cursor move implementation to use TextEditorSelectionSource.PROGRAMMATIC when noHistory is true

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/vs/editor/common/cursor/cursorMoveCommands.ts Added noHistory parameter to interface, validation, schema, and parsing logic
src/vs/editor/browser/coreCommands.ts Updated cursor move implementation to conditionally use programmatic source when noHistory is true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add arg to cursorMove command to not add the movement to navigation history

2 participants