Skip to content

Extensibility API: openTextDocument() inconsistent dirty state with working files if document is inside workspace.rootPath #1353

Closed
@bgse

Description

@bgse

Sorry for the convoluted title, also sorry if this is simply user error or misuse of the API.

Long story short, I'm opening the TextDocument like this:

vscode.workspace.openTextDocument(vscode.Uri.parse("untitled:" + lsFullpath)).then(...);

where lsFullpath is a full path inside vscode.workspace.rootPath, and immediately call

TextDocument.save()

This has the intended effect (which might be the API misuse) that a new file (and required non-existent subfolders) is created in the workspace.

However, the working files now have the new file with a dirty marker.

Also, browsing to the file in the workspace (not working files) and opening in the editor and changing it creates a 2nd entry in working files, obviously also dirty at this point.

Saving the file removes dirty marker from the 2nd entry in working files, but changes are not propagated to the 1st entry.

Now selecting 1st entry in working files and saving it kicks out 2nd entry from working files, and overwrites the file (which I guess is to be expected).

This came up trying for a quick solution for #1169

Metadata

Metadata

Assignees

Labels

apibugIssue identified by VS Code Team member as probable bugverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions