Add noHistory argument to cursorMove command to skip navigation history #270385
+19
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 causedworkbench.action.navigateBack
andworkbench.action.navigateForward
commands to replay all these intermediate cursor positions, making navigation history essentially unusable for users with such keybindings.For example:
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 thecursorMove
command. When set totrue
, cursor movements are not added to navigation history.The implementation works by using
TextEditorSelectionSource.PROGRAMMATIC
as the source whennoHistory
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
Changes
noHistory?: boolean
toCursorMove.RawArguments
interface_runCursorMove()
to useTextEditorSelectionSource.PROGRAMMATIC
whennoHistory
is trueBackward Compatibility
The
noHistory
argument is optional and defaults tofalse
, so existing keybindings and code that don't specify it will continue to work exactly as before.Fixes #<issue_number>
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.