Skip to content

Extension Development: Offer a way to "clear undos" for specific filesystem scheme(s) or document(s).  #104693

@boltex

Description

@boltex

I know there exists an 'all-or-nothing" configuration option that prevents it globally (files.restoreUndoStack), but I would need a less drastic method for a better user experience so as not to force this setting globally on all files...

USE CASE:
My extension (https://github.com/boltex/leointeg) uses vscode's filesystem provider api to implement custom 'editors' for my needs, (a temporary scratch pad) as indicated in the documentation here https://code.visualstudio.com/api/extension-guides/virtual-documents#file-system-api .

I need to be able to 'block' or 'clear' undos when closing or switching from one of them to another. (e.g. resetting the scratchpad)

OLD WORKAROUND:
It used to be that doing vscode.WorkspaceEdit "rename" operation would 'clear' or 'block' all undos for the newly named document. And as such effectively prevented them to traverse across the point where the document was renamed. Which was a desired outcome in my use case.

But lately, the newer versions of vscode tries to uphlod undo operations past a 'rename' or 'save as new name"... This is problematic for when a clear document separation was intended with the 'rename' operation... More specifically: This new problematic behavior opens a document with the old name when pressing ctrl+Z on a newly renamed document (in a custom filesystem)... Is there a way to disable that? Or a way to clear the undo stack for a given document URL? or for a filesystem scheme only in particular?

PROPOSED SOLUTION(S):

  • Provide a command, or a vscode.WorkspaceEdit action, to clear undo stack of a given document, or filesystem scheme.
  • Provide a way to opt-out specific file scheme(s) from the 'persist undos across closed/renamed/saved' files behavior (similar to files.restoreUndoStack config option, but for specific schemes)
  • Make an explicit side-effect of clearing the document history of a file that it also clears any undo stack associated with it, i.e. the vscode.commands.executeCommand('vscode.removeFromRecentlyOpened', p_textEditor.document.uri.path); command.

Thank you for your consideration!
Edit: typo

Metadata

Metadata

Assignees

Labels

*out-of-scopePosted issue is not in scope of VS Codeinfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions