diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 24d3391bc2c..cd38535f5f6 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -183,7 +183,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I const extHostWebviewViews = rpcProtocol.set(ExtHostContext.ExtHostWebviewViews, new ExtHostWebviewViews(rpcProtocol, extHostWebviews)); const extHostTesting = rpcProtocol.set(ExtHostContext.ExtHostTesting, new ExtHostTesting(rpcProtocol, extHostCommands)); const extHostUriOpeners = rpcProtocol.set(ExtHostContext.ExtHostUriOpeners, new ExtHostUriOpeners(rpcProtocol)); - rpcProtocol.set(ExtHostContext.ExtHostInteractive, new ExtHostInteractive(rpcProtocol, extHostNotebook, extHostDocumentsAndEditors, extHostCommands)); + rpcProtocol.set(ExtHostContext.ExtHostInteractive, new ExtHostInteractive(rpcProtocol, extHostNotebook, extHostDocumentsAndEditors, extHostCommands, extHostLogService)); // Check that no named customers are missing const expected = Object.values>(ExtHostContext); diff --git a/src/vs/workbench/api/common/extHostInteractive.ts b/src/vs/workbench/api/common/extHostInteractive.ts index b492b0c9ed4..b53d846c2e1 100644 --- a/src/vs/workbench/api/common/extHostInteractive.ts +++ b/src/vs/workbench/api/common/extHostInteractive.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { URI, UriComponents } from 'vs/base/common/uri'; +import { ILogService } from 'vs/platform/log/common/log'; import { ExtHostInteractiveShape, IMainContext } from 'vs/workbench/api/common/extHost.protocol'; import { ApiCommand, ApiCommandArgument, ApiCommandResult, ExtHostCommands } from 'vs/workbench/api/common/extHostCommands'; import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors'; @@ -15,7 +16,8 @@ export class ExtHostInteractive implements ExtHostInteractiveShape { mainContext: IMainContext, private _extHostNotebooks: ExtHostNotebookController, private _textDocumentsAndEditors: ExtHostDocumentsAndEditors, - private _commands: ExtHostCommands + private _commands: ExtHostCommands, + _logService: ILogService ) { const openApiCommand = new ApiCommand( 'interactive.open', @@ -28,10 +30,13 @@ export class ExtHostInteractive implements ExtHostInteractiveShape { new ApiCommandArgument('title', 'Interactive editor title', v => true, v => v) ], new ApiCommandResult<{ notebookUri: UriComponents; inputUri: UriComponents; notebookEditorId?: string }, { notebookUri: URI; inputUri: URI; notebookEditor?: NotebookEditor }>('Notebook and input URI', (v: { notebookUri: UriComponents; inputUri: UriComponents; notebookEditorId?: string }) => { + _logService.debug('[ExtHostInteractive] open iw with notebook editor id', v.notebookEditorId); if (v.notebookEditorId !== undefined) { const editor = this._extHostNotebooks.getEditorById(v.notebookEditorId); + _logService.debug('[ExtHostInteractive] notebook editor found', editor.id); return { notebookUri: URI.revive(v.notebookUri), inputUri: URI.revive(v.inputUri), notebookEditor: editor.apiEditor }; } + _logService.debug('[ExtHostInteractive] notebook editor not found, uris for the interactive document', v.notebookUri, v.inputUri); return { notebookUri: URI.revive(v.notebookUri), inputUri: URI.revive(v.inputUri) }; }) ); diff --git a/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts b/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts index 8b70cab1d33..f108213e01b 100644 --- a/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts +++ b/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts @@ -31,6 +31,7 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { ILogService } from 'vs/platform/log/common/log'; import { Registry } from 'vs/platform/registry/common/platform'; import { contrastBorder, listInactiveSelectionBackground, registerColor, transparent } from 'vs/platform/theme/common/colorRegistry'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; @@ -344,6 +345,7 @@ registerAction2(class extends Action2 { const editorGroupService = accessor.get(IEditorGroupsService); const historyService = accessor.get(IInteractiveHistoryService); const kernelService = accessor.get(INotebookKernelService); + const logService = accessor.get(ILogService); const group = columnToEditorGroup(editorGroupService, typeof showOptions === 'number' ? showOptions : showOptions?.viewColumn); const editorOptions = { activation: EditorActivation.PRESERVE, @@ -351,9 +353,11 @@ registerAction2(class extends Action2 { }; if (resource && resource.scheme === Schemas.vscodeInteractive) { + logService.debug('Open interactive window from resource:', resource.toString()); const resourceUri = URI.revive(resource); const editors = editorService.findEditors(resourceUri).filter(id => id.editor instanceof InteractiveEditorInput && id.editor.resource?.toString() === resourceUri.toString()); if (editors.length) { + logService.debug('Find existing interactive window:', resource.toString()); const editorInput = editors[0].editor as InteractiveEditorInput; const currentGroup = editors[0].groupId; const editor = await editorService.openEditor(editorInput, editorOptions, currentGroup); @@ -384,6 +388,8 @@ registerAction2(class extends Action2 { counter++; } while (existingNotebookDocument.has(notebookUri.toString())); + logService.debug('Open new interactive window:', notebookUri.toString(), inputUri.toString()); + if (id) { const allKernels = kernelService.getMatchingKernel({ uri: notebookUri, viewType: 'interactive' }).all; const preferredKernel = allKernels.find(kernel => kernel.id === id); @@ -397,6 +403,7 @@ registerAction2(class extends Action2 { const editorPane = await editorService.openEditor(editorInput, editorOptions, group); const editorControl = editorPane?.getControl() as { notebookEditor: NotebookEditorWidget | undefined; codeEditor: CodeEditorWidget } | undefined; // Extensions must retain references to these URIs to manipulate the interactive editor + logService.debug('New interactive window opened. Notebook editor id', editorControl?.notebookEditor?.getId()); return { notebookUri, inputUri, notebookEditorId: editorControl?.notebookEditor?.getId() }; } });