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

window.tabs after vscode.open command is not up to date #139786

Closed
bpasero opened this issue Dec 27, 2021 · 6 comments
Closed

window.tabs after vscode.open command is not up to date #139786

bpasero opened this issue Dec 27, 2021 · 6 comments
Assignees
Labels
api bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders verified Verification succeeded workbench-editors Managing of editor widgets in workbench window
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented Dec 27, 2021

I just pushed a test for asserting vscode.open command properly applies the ViewColumn argument and my initial idea was to use the window.tabs API for that purpose, but as it turns out, awaiting executeCommand and then calling window.tabs does not work, maybe (?) because of the micro queue that puts the events at the end?

Using window.activeTextEditor.viewColumn however seems to work, and I wonder if we need to make window.tabs also work so that extensions see a consistent picture.

If we don't want to drop the micro task then maybe those commands that leverage editors need to await the tabs model being synced back to the extension host?

//cc @jrieken

@bpasero bpasero added api debt Code quality issues workbench-editors Managing of editor widgets in workbench window labels Dec 27, 2021
@lramos15
Copy link
Member

This is interesting as I feel like the tab tests do something similar but they use open and show text document for the most part.

For example we use execute command to get a diff here and then check windows.tab

await commands.executeCommand('vscode.diff', leftDiff, rightDiff, 'Diff', { viewColumn: ViewColumn.Three, preview: false });
const tabs = window.tabs;
assert.strictEqual(tabs.length, 5);

@bpasero
Copy link
Member Author

bpasero commented Dec 28, 2021

@lramos15 but you are not testing for activeTab, just add this and it fails after line 397:

assert.strictEqual(window.activeTab?.viewColumn, ViewColumn.Three);

@lramos15
Copy link
Member

@bpasero I just tested this again now that we removed microtask and it's still incorrect. Will have to dig deeper but that doesn't seem like it was it.

@bpasero
Copy link
Member Author

bpasero commented Feb 17, 2022

Is it possible that the executeCommand simply returns to the extension host before you were pushing the updated tabs model to the extension host? Maybe there is a missing await in vscode.open that does not exist in the other ways for opening.

@lramos15 lramos15 added bug Issue identified by VS Code Team member as probable bug and removed debt Code quality issues labels Feb 17, 2022
@lramos15 lramos15 added this to the February 2022 milestone Feb 17, 2022
@lramos15
Copy link
Member

I thin I must've messed up testing / fixed it with my if (!editorIndex) fix. Seems to work now and I added a test. Don't know if you want to update your vscode.open tests as well

@bpasero bpasero added the verified Verification succeeded label Feb 23, 2022
@bpasero
Copy link
Member Author

bpasero commented Feb 23, 2022

verified via 6dee30b

@github-actions github-actions bot locked and limited conversation to collaborators Apr 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders verified Verification succeeded workbench-editors Managing of editor widgets in workbench window
Projects
None yet
Development

No branches or pull requests

3 participants
@bpasero @lramos15 and others