VSCodeVim / VSCodeVim/Vim

Undo on text editor of a webview (custom text editor) rolls back the whole stack

Open
#6,248 0 comments 0 reactions 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

Describe the bug
I have a CustomTextEditor in my extension, with "priority: "option"". Whenever the webview edits the text file, the consequent edits will be undone by 1 'u' key press. ctrl-z works right.

To Reproduce
Steps to reproduce the behavior:

  1. Clone vscode-extension-samples
  2. Go to the ...\vscode-extension-samples\custom-editor-sample\
  3. Change the catScratch custom editor to be priority option>
diff --git a/custom-editor-sample/package.json b/custom-editor-sample/package.json
index 38801cc..1813089 100644
--- a/custom-editor-sample/package.json
+++ b/custom-editor-sample/package.json
@@ -29,7 +29,8 @@
 					{
 						"filenamePattern": "*.cscratch"
 					}
-				]
+				],
+				"priority": "option"
 			},
 			{
 				"viewType": "catCustoms.pawDraw",
  1. Start the extension.
  2. Open example.cscratch
  3. Split right
  4. On the right side "Reopen Editor With..." -> Cat Scratch
  5. Add 2 "scratch" with the "Scratch!" button
  6. Select the text editor
  7. Press 'u'

Expected behavior
The editor undoes 1 scratch added. Just like pressing ctrl-z.

Screenshots
https://i.imgur.com/qD1yY8G.gif

Environment (please complete the following information):

  • Extension (VsCodeVim) version: v1.18.9
  • VSCode version: VSCodium 1.53.2 (system setup)
  • OS: Windows_NT x64 10.0.18363

Additional context

    "vim.otherModesKeyBindings": [
        {
            "before": [
                "u"
            ],
            "after": [],
            "commands": [
                {
                    "command": "undo"
                }
            ]
        },
        {
            "before": [
                "<C-r>"
            ],
            "after": [],
            "commands": [
                {
                    "command": "redo"
                }
            ]
        }
    ]

In user settings.json did not help. It might be considered a reliable reproduction of the issue #2007 .

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

Reproduce the behavior with custom-editor-sample/package.json, the Cat Scratch custom editor, and the vim.otherModesKeyBindings configuration shown in the issue. Start by tracing how the configured undo command is handled for a webview-backed text editor and compare it with Ctrl-Z. Done means one press of “u” undoes only the most recent scratch edit, matching Ctrl-Z.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
tooling
Issue type
Bug
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.