-
Notifications
You must be signed in to change notification settings - Fork 34.4k
differentiate notebook moving to new group and splitting #98607
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
Conversation
// NotebookRegistry.releaseNotebookEditorWidget(originalInput); | ||
// NotebookRegistry.claimNotebookEditorWidget(copiedInput, widgetRef); | ||
// } | ||
if (!options?.shouldCreateNewWhenOverride) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bpasero here we check if it's splitting or moving by reading shouldCreateNewWhenOverride, if it's just moving the editor, the new editor input will claim ownership of the NotebookEditorWidget (which is a detached DOM node).
Write
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a big fan of adding a new editor option that is only being set internally from the editor group view. The intent of editor options is to use them from the outside when opening an editor, but not hide internals in there.
Wouldn't it make more sense to maybe add some kind of context to the editor override facilities that tell you why an editor is opening and then act accordingly? That seems like the right place to me to put this kind of information.
@bpasero thanks for the feedback, makes sense that we should not pollute the The Firstly, the info is transferred through export interface IEditorGroup {
- openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions): Promise<IEditorPane | null>;
+ openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions, keepCopy?: boolean): Promise<IEditorPane | null>;
} and then we pass the info to editorOverrides async openEditor(editor: EditorInput, options?: EditorOptions, keepCopy?: boolean): Promise<IEditorPane | null> {
// Guard against invalid inputs
if (!editor) {
return null;
}
// Editor opening event allows for prevention
- const event = new EditorOpeningEvent(this._group.id, editor, options);
+ const event = new EditorOpeningEvent(this._group.id, editor, options, keepCopy);
this._onWillOpenEditor.fire(event);
const prevented = event.isPrevented();
if (prevented) {
return withUndefinedAsNull(await prevented());
}
// Proceed with opening
return withUndefinedAsNull(await this.doOpenEditor(editor, options));
} and lastly @bpasero how do you like it now? The challenge here is editor overrides are triggered when an editor is opened |
@rebornix Maybe not a bare vscode/src/vs/workbench/common/editor.ts Line 318 in da8f44c
|
Yes, an enum is better. I'll update the PR> |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall good with me, some polish maybe:
OpenEditorInGroupContext
=>OpenEditorContext
- the enum should initialize its first value to be
1
and not0
so that we prevent bad checks - I see no tests that verify the event carries the proper context, please add it
@bpasero the short summary for the PR is differentiating Move Editor to New Group and Splitting Editors. Please let me know if there is any better way to archive the same thing.
Currently
EditorOverride
doesn't have enough information about whether users are splitting an editor or just moving an editor to another editor group. It's fine for Monaco Editor as recreating the view/models for the editor is cheap while for Notebook (and potentially any editor using webview), we can't do that as recreating a new editor means the intermediate of the webview is lost.The workflow for moving an editor to a new group
For moving notebook editor to a new group, we want to reuse the
NotebookEditorWidget
referenced in previous Notebook Editor, however we don't know if it's safe to do so aseditorGroupView.closeEditor(input)
happens after we create the new editor in the new group. In this PR, I tried to give this information toEditorOverride
and they can decide if they should create a complete new editor or not.