Undo on text editor of a webview (custom text editor) rolls back the whole stack
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:
- Clone vscode-extension-samples
- Go to the ...\vscode-extension-samples\custom-editor-sample\
- 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",
- Start the extension.
- Open example.cscratch
- Split right
- On the right side "Reopen Editor With..." -> Cat Scratch
- Add 2 "scratch" with the "Scratch!" button
- Select the text editor
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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