diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts index 0904ce3b0db..57b824f2a86 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts @@ -64,6 +64,7 @@ import { IChatAttachmentResolveService } from '../../chat/browser/chatAttachment import { INotebookService } from '../../notebook/common/notebookService.js'; import { ICellEditOperation } from '../../notebook/common/notebookCommon.js'; import { INotebookEditor } from '../../notebook/browser/notebookBrowser.js'; +import { isNotebookContainingCellEditor as isNotebookWithCellEditor } from '../../notebook/browser/notebookEditor.js'; export const enum State { CREATE_SESSION = 'CREATE_SESSION', @@ -1425,7 +1426,7 @@ export class InlineChatController2 implements IEditorContribution { const session = visibleSessionObs.read(r); const entry = session?.editingSession.readEntry(session.uri, r); - const pane = this._editorService.visibleEditorPanes.find(candidate => candidate.getControl() === this._editor); + const pane = this._editorService.visibleEditorPanes.find(candidate => candidate.getControl() === this._editor || isNotebookWithCellEditor(candidate, this._editor)); if (pane && entry) { entry?.getEditorIntegration(pane); } diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts index b289cdb6142..07797b8b41a 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts @@ -24,7 +24,7 @@ import { ITelemetryService } from '../../../../platform/telemetry/common/telemet import { IThemeService } from '../../../../platform/theme/common/themeService.js'; import { Selection } from '../../../../editor/common/core/selection.js'; import { EditorPane } from '../../../browser/parts/editor/editorPane.js'; -import { DEFAULT_EDITOR_ASSOCIATION, EditorPaneSelectionChangeReason, EditorPaneSelectionCompareResult, EditorResourceAccessor, IEditorMemento, IEditorOpenContext, IEditorPaneScrollPosition, IEditorPaneSelection, IEditorPaneSelectionChangeEvent, IEditorPaneWithScrolling, createEditorOpenError, createTooLargeFileError, isEditorOpenError } from '../../../common/editor.js'; +import { DEFAULT_EDITOR_ASSOCIATION, EditorPaneSelectionChangeReason, EditorPaneSelectionCompareResult, EditorResourceAccessor, IEditorMemento, IEditorOpenContext, IEditorPane, IEditorPaneScrollPosition, IEditorPaneSelection, IEditorPaneSelectionChangeEvent, IEditorPaneWithScrolling, createEditorOpenError, createTooLargeFileError, isEditorOpenError } from '../../../common/editor.js'; import { EditorInput } from '../../../common/editor/editorInput.js'; import { SELECT_KERNEL_ID } from './controller/coreActions.js'; import { INotebookEditorOptions, INotebookEditorPane, INotebookEditorViewState } from './notebookBrowser.js'; @@ -48,6 +48,7 @@ import { ILogService } from '../../../../platform/log/common/log.js'; import { IPreferencesService } from '../../../services/preferences/common/preferences.js'; import { IActionViewItemOptions } from '../../../../base/browser/ui/actionbar/actionViewItems.js'; import { StopWatch } from '../../../../base/common/stopwatch.js'; +import { ICodeEditor } from '../../../../editor/browser/editorBrowser.js'; const NOTEBOOK_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'NotebookEditorViewState'; @@ -658,3 +659,17 @@ class NotebookEditorSelection implements IEditorPaneSelection { return this.cellUri.fragment; } } + +export function isNotebookContainingCellEditor(editor: IEditorPane | undefined, codeEditor: ICodeEditor): boolean { + if (editor?.getId() === NotebookEditor.ID) { + const notebookWidget = editor.getControl() as NotebookEditorWidget; + if (notebookWidget) { + for (const [_, editor] of notebookWidget.codeEditors) { + if (editor === codeEditor) { + return true; + } + } + } + } + return false; +}