mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
simplify get notebook widget from uri.
This commit is contained in:
parent
3083715556
commit
1b5b6df54f
|
@ -255,7 +255,7 @@ registerAction2(class extends Action2 {
|
|||
if (editors.length) {
|
||||
const editorInput = editors[0].editor as InteractiveEditorInput;
|
||||
const currentGroup = editors[0].groupId;
|
||||
await editorService.openEditor(editorInput, undefined, currentGroup);
|
||||
await editorService.openEditor(editorInput, { preserveFocus: false }, currentGroup);
|
||||
return {
|
||||
notebookUri: editorInput.resource!,
|
||||
inputUri: editorInput.inputResource
|
||||
|
|
|
@ -121,19 +121,8 @@ function getContextFromActiveEditor(editorService: IEditorService): INotebookAct
|
|||
}
|
||||
|
||||
function getWidgetFromUri(accessor: ServicesAccessor, uri: URI) {
|
||||
const editorService = accessor.get(IEditorService);
|
||||
const notebookEditorService = accessor.get(INotebookEditorService);
|
||||
const editorId = editorService.getEditors(EditorsOrder.SEQUENTIAL).find(editorId => editorId.editor instanceof NotebookEditorInput && editorId.editor.resource?.toString() === uri.toString());
|
||||
if (!editorId) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const notebookEditorInput = editorId.editor as NotebookEditorInput;
|
||||
if (!notebookEditorInput.resource) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const widget = notebookEditorService.listNotebookEditors().find(widget => widget.textModel?.viewType === notebookEditorInput.viewType && widget.textModel?.uri.toString() === notebookEditorInput.resource.toString());
|
||||
const widget = notebookEditorService.listNotebookEditors().find(widget => widget.hasModel() && widget.textModel.uri.toString() === uri.toString());
|
||||
|
||||
if (widget && widget.hasModel()) {
|
||||
return widget;
|
||||
|
|
Loading…
Reference in a new issue