Allow showTextDocument to open notebook cell URIs (#158477)

* Fix #123270

* Update to use `getCodeEditor`
This commit is contained in:
Logan Ramos
2022-08-30 06:39:00 -04:00
committed by GitHub
parent 933c22a53f
commit a2cd34f347
3 changed files with 13 additions and 6 deletions

View File

@@ -188,7 +188,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = {
assert.strictEqual(firstNotebookEditor?.notebook, secondNotebookEditor?.notebook, 'split notebook editors share the same document');
});
test.skip('#106657. Opening a notebook from markers view is broken ', async function () {
test('#106657. Opening a notebook from markers view is broken ', async function () {
const document = await openRandomNotebookDocument();
const [cell] = document.getCells();

View File

@@ -1227,6 +1227,10 @@ export function getCodeEditor(thing: unknown): ICodeEditor | null {
return thing.getModifiedEditor();
}
if (isCompositeEditor(thing) && isCodeEditor(thing.activeCodeEditor)) {
return thing.activeCodeEditor;
}
return null;
}

View File

@@ -13,7 +13,7 @@ import { ISelection } from 'vs/editor/common/core/selection';
import { IDecorationOptions, IDecorationRenderOptions } from 'vs/editor/common/editorCommon';
import { ISingleEditOperation } from 'vs/editor/common/core/editOperation';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { ITextEditorOptions, IResourceEditorInput, EditorActivation } from 'vs/platform/editor/common/editor';
import { ITextEditorOptions, IResourceEditorInput, EditorActivation, EditorResolution } from 'vs/platform/editor/common/editor';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { MainThreadTextEditor } from 'vs/workbench/api/browser/mainThreadEditor';
import { ExtHostContext, ExtHostEditorsShape, IApplyEditsOptions, ITextDocumentShowOptions, ITextEditorConfigurationUpdate, ITextEditorPositionData, IUndoStopOptions, MainThreadTextEditorsShape, TextEditorRevealType } from 'vs/workbench/api/common/extHost.protocol';
@@ -25,8 +25,8 @@ import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/wo
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { ILineChange } from 'vs/editor/common/diff/smartLinesDiffComputer';
import { IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers';
import { DEFAULT_EDITOR_ASSOCIATION, IEditorControl } from 'vs/workbench/common/editor';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IEditorControl } from 'vs/workbench/common/editor';
import { getCodeEditor, ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
export interface IMainThreadEditorLocator {
@@ -127,7 +127,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
// preserve pre 1.38 behaviour to not make group active when preserveFocus: true
// but make sure to restore the editor to fix https://github.com/microsoft/vscode/issues/79633
activation: options.preserveFocus ? EditorActivation.RESTORE : undefined,
override: DEFAULT_EDITOR_ASSOCIATION.id
override: EditorResolution.EXCLUSIVE_ONLY
};
const input: IResourceEditorInput = {
@@ -139,7 +139,10 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
if (!editor) {
return undefined;
}
return this._editorLocator.findTextEditorIdFor(editor);
// Composite editors are made up of many editors so we return the active one at the time of opening
const editorControl = editor.getControl();
const codeEditor = getCodeEditor(editorControl);
return codeEditor ? this._editorLocator.getIdOfCodeEditor(codeEditor) : undefined;
}
async $tryShowEditor(id: string, position?: EditorGroupColumn): Promise<void> {