simplify get notebook widget from uri.

This commit is contained in:
rebornix 2021-06-28 12:06:56 -07:00
parent 3083715556
commit 1b5b6df54f
2 changed files with 2 additions and 13 deletions

View file

@ -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

View file

@ -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;