Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onDidChangeTextDocument and onDidCloseTextDocument fired when adding/removing workspaces #42666

Closed
octref opened this issue Jan 31, 2018 · 2 comments
Assignees
Labels
api *as-designed Described behavior is as designed workbench-multiroot Multi-root (multiple folders) issues

Comments

@octref
Copy link
Contributor

octref commented Jan 31, 2018

Testing #42195

I noticed this because of a bunch of errors from Vim when I'm adding/removing workspaces.

Have this as an extension

export const activate = (context: vscode.ExtensionContext) => {
  vscode.workspace.onDidChangeTextDocument((e) => {
    console.log(e.document.fileName)
  })
  vscode.workspace.onDidCloseTextDocument((e) => {
    console.log(e.fileName)
  })
}

And try adding/removing folders using either the UI or the API.

I'm getting onDidChangeTextDocument and onDidCloseTextDocument for /Users/octref/Desktop/test.code-workspace, which sort of make sense, but I don't think they should apply to the workspace file itself, especially when that file is outside of any active workspaces.

However when adding workspaces, I also get onDidChangeTextDocument where e.document.fileName points to /launch and e.contentChanges[0].text looks like this, which is quite unexpected...

"{"id":"vscode://schemas/launch","type":"object","title":"Launch","required":[],"default":{"version":"0.2.0","configurations":[],"compounds":[]},"properties":{"version":{"type":"string","description":"Version of this file format.","default":"0.2.0"},"configurations":{"type":"array","description":"List of configurations. Add new configurations or edit existing ones by using IntelliSense."
@octref octref added api workbench-multiroot Multi-root (multiple folders) issues labels Jan 31, 2018
@bpasero
Copy link
Member

bpasero commented Feb 1, 2018

I would say that this is expected since we use the model API to make changes to certain files (e.g. the code workspace file) and they end up being synchronized to the extension host. @jrieken to confirm.

@bpasero bpasero assigned jrieken and unassigned bpasero Feb 1, 2018
@jrieken jrieken added the *as-designed Described behavior is as designed label Feb 1, 2018
@jrieken
Copy link
Member

jrieken commented Feb 1, 2018

Yeah, as designed

@jrieken jrieken closed this as completed Feb 1, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api *as-designed Described behavior is as designed workbench-multiroot Multi-root (multiple folders) issues
Projects
None yet
Development

No branches or pull requests

3 participants