Skip to content

DiffEditor: Revert a hunk or selection via keyboard #225879

@hron

Description

@hron

Type: Feature Request

Currently, it's impossible to revert a diff hunk or selection under the cursor in the diff editor. Even though, there is diffEditor.revert action it cannot be used when assigned to a keyboard shortcut because it assumes to be called via gutter icon only.

To reproduce the issue:

  1. Assign diffEditor.revert to a keyboard shortcut like that:
    {
        "key": "ctrl+alt+z",
        "command": "diffEditor.revert",
        "when": "inDiffEditor"
    }
  1. Run VSCode to compare some files, e.g. code --diff /tmp/test1.txt /tmp/test2.txt
  2. Navigate to a diff hunk
  3. Press ctrl+alt+z

Expected results:

The hunk under cursor should be reverted.

Actual results:

VSCode just raises a notification with error "Cannot read properties of undefined (reading 'originalUri')"

VS Code version: Code - Insiders 1.93.0-insider (d751e43, 2024-08-16T05:03:54.591Z)
OS version: Linux x64 6.8.0-40-generic
Modes:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions