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

A second instance of a notebook is opened when debugging with two editor groups #133761

Open
roblourens opened this issue Sep 24, 2021 · 19 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug notebook-perf workbench-editors Managing of editor widgets in workbench window
Milestone

Comments

@roblourens
Copy link
Member

roblourens commented Sep 24, 2021

  • Open a notebook in one editor group 1, and a editor group 2 with anything in it
  • Start RBL in the notebook
  • Focus group 2
  • Open the debug view, click the stack frame for the notebook cell (there are other ways to make this happen too)
  • A second notebook editor instance is opened in group 2

We just call openEditor and it should reveal the cell in the editor where it's already open. But I think that we can't do this correctly for notebook cells. Where is the code that checks whether the editor is already open?

image

@lramos15
Copy link
Member

Simpler repo without debugging.

  1. Open a github issue notebook
  2. Create an error
  3. Focus a different group
  4. Click the problem in the problems panel
  5. 🐛 New notebook appears

@lramos15 lramos15 added bug Issue identified by VS Code Team member as probable bug notebook workbench-editors Managing of editor widgets in workbench window labels Sep 24, 2021
@bpasero
Copy link
Member

bpasero commented Sep 24, 2021

This is probably a duplicate of #131619

Here is what happens:

  • you click on a problem
  • we open an untyped input as shown below
  • we ask the notebook if it matches that input
  • notebook says, it doesn't match
  • we consider the right hand empty group as target

image

Our weak hack does not work in this case because a cell URI is opened:

// Note: intentionally doing a "weak" check on the resource
// because `EditorInput.matches` will not work for untyped
// editors that have no `override` defined.
//
// TODO@lramos15 https://github.com/microsoft/vscode/issues/131619
if (typedEditor.resource) {
return isEqual(typedEditor.resource, EditorResourceAccessor.getCanonicalUri(editor));
}

We have to stop calling findGroup with untyped editors because they will never match properly.

@bpasero bpasero removed their assignment Sep 24, 2021
@lramos15
Copy link
Member

  • we ask the notebook if it matches that input

This sounds like an easy enough fix then. The notebook knows how to translate a cell URI into the notebook URI. That's what it should use to determine the group

@bpasero
Copy link
Member

bpasero commented Sep 24, 2021

Yeah it is a workaround if it is possible for a typed notebook input to know the cell it contains, would have to go somewhere here:

if (otherInput instanceof NotebookEditorInput) {
return this.viewType === otherInput.viewType && isEqual(this.resource, otherInput.resource);
}

@roblourens
Copy link
Member Author

So matches should return true if the other is a cell inside this notebook? That's easy enough but could there be any other consequences that I should watch out for?

@lramos15
Copy link
Member

I don't think there's any consequences as you effectively want each cell to be considered the same input as the parent notebook.

@roblourens roblourens added this to the October 2021 milestone Sep 27, 2021
@roblourens
Copy link
Member Author

If you say so... not gonna touch it for September though

@lramos15 lramos15 removed their assignment Oct 13, 2021
@rebornix rebornix removed the notebook label Oct 21, 2021
@rebornix
Copy link
Member

rebornix commented Oct 26, 2021

@roblourens do we still want to change the behavior now or we do it early next week? Pushing to Nov first.

@rebornix rebornix modified the milestones: October 2021, November 2021 Oct 26, 2021
@roblourens
Copy link
Member Author

I guess next month

rebornix added a commit that referenced this issue Nov 10, 2021
This reverts commit ec2b75a.
@lramos15
Copy link
Member

Reopening because fix was reverted

@lramos15 lramos15 reopened this Nov 10, 2021
@lramos15
Copy link
Member

@bpasero Talked with @rebornix a bit and matches cannot match for cell uris in this case as they actually want to create and resolve a new editor input which we do not do if the active editor matches the passed in one as it is normally unnecessary work. I was wondering if they should add special logic here

function matchesEditor(typedEditor: EditorInput, editor: EditorInput | IUntypedEditorInput): boolean {
if (typedEditor.matches(editor)) {
return true;
}
// Note: intentionally doing a "weak" check on the resource
// because `EditorInput.matches` will not work for untyped
// editors that have no `override` defined.
//
// TODO@lramos15 https://github.com/microsoft/vscode/issues/131619
if (typedEditor.resource) {
return isEqual(typedEditor.resource, EditorResourceAccessor.getCanonicalUri(editor));
}
return false;
}
to have the notebook and cell uri match so that the group chosen is correct. I know it's not ideal because it is notebook specific

@bpasero
Copy link
Member

bpasero commented Nov 11, 2021

Would #131619 address this too?

@lramos15
Copy link
Member

@bpasero I think so as the cell uri is finding the incorrect target group. If the editor input created was opened in the correct group it would simply reveal the notebook and scroll it as expected.

@rebornix rebornix modified the milestones: November 2021, December 2021 Dec 1, 2021
@rebornix rebornix modified the milestones: January 2022, Backlog Jan 27, 2022
@rebornix rebornix modified the milestones: Backlog, December 2022 Dec 7, 2022
@roblourens
Copy link
Member Author

I don't understand what has to be done here. Any change a year later?

@rebornix rebornix removed their assignment Dec 8, 2022
@lramos15
Copy link
Member

@roblourens I don't believe we will be able to fix this until #131619 is addressed

@roblourens
Copy link
Member Author

Why is that one related?

For future reference, here are my notes from our call a couple weeks ago

  • In NotebookServiceImpl, add a separate editor registration for the Untitled- pattern, and look up the matching open editor input, set the cellOptions to reveal the cell, and return that
  • Could possibly reduce the number of factories by just registering one for all registered editor types, in one glob

@lramos15
Copy link
Member

Why is that one related?

For future reference, here are my notes from our call a couple weeks ago

  • In NotebookServiceImpl, add a separate editor registration for the Untitled- pattern, and look up the matching open editor input, set the cellOptions to reveal the cell, and return that
  • Could possibly reduce the number of factories by just registering one for all registered editor types, in one glob

Those notes are for the untitled issue this is for something else. The issue here is that the Cell URI doesn't match the notebook URI in the matches call so we improperly select the second group and then it resolves to the exact same notebook causing two to be opened. The reason we have to call this matches before resolution is complete and not after is due to webviews needing to know what group they belong to. Ideally an editor input is group agnostic which is why we hope @mjbvz can eventually resolve #131619 as there are some issues that just cannot be fixed in a proper manner without it,

@roblourens roblourens modified the milestones: January 2023, Backlog Dec 19, 2022
@roblourens
Copy link
Member Author

Oops, thanks. #166161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug notebook-perf workbench-editors Managing of editor widgets in workbench window
Projects
None yet
Development

No branches or pull requests

6 participants
@roblourens @rebornix @bpasero @lramos15 @tanhakabir and others