Skip to content

Commit 989da1f

Browse files
authored
Merge pull request #246021 from eleanorjboyd/fond-minnow
Fix regression with open cell output in editor
2 parents ff52d07 + 7ec9bc9 commit 989da1f

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

src/vs/workbench/browser/labels.ts

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -492,31 +492,33 @@ class ResourceLabelWidget extends IconLabel {
492492
if (!options.forceLabel && !isSideBySideEditor && resource?.scheme === Schemas.vscodeNotebookCellOutput) {
493493
const notebookDocument = this.notebookDocumentService.getNotebook(resource);
494494
const outputUriData = extractCellOutputDetails(resource);
495-
if (!outputUriData?.notebook || !outputUriData.cellFragment) {
496-
return;
497-
}
498-
const cellUri = outputUriData.notebook.with({
499-
scheme: Schemas.vscodeNotebookCell,
500-
fragment: outputUriData.cellFragment
501-
});
502-
const cellIndex = notebookDocument?.getCellIndex(cellUri);
503-
const outputIndex = outputUriData.outputIndex;
504-
505-
if (cellIndex !== undefined && outputIndex !== undefined && typeof label.name === 'string') {
506-
label.name = localize(
507-
'notebookCellOutputLabel',
508-
"{0} • Cell {1} • Output {2}",
509-
label.name,
510-
`${cellIndex + 1}`,
511-
`${outputIndex + 1}`
512-
);
513-
} else if (cellIndex !== undefined && typeof label.name === 'string') {
514-
label.name = localize(
515-
'notebookCellOutputLabelSimple',
516-
"{0} • Cell {1} • Output",
517-
label.name,
518-
`${cellIndex + 1}`
519-
);
495+
if (outputUriData?.cellFragment) {
496+
if (!outputUriData.notebook) {
497+
return;
498+
}
499+
const cellUri = outputUriData.notebook.with({
500+
scheme: Schemas.vscodeNotebookCell,
501+
fragment: outputUriData.cellFragment
502+
});
503+
const cellIndex = notebookDocument?.getCellIndex(cellUri);
504+
const outputIndex = outputUriData.outputIndex;
505+
506+
if (cellIndex !== undefined && outputIndex !== undefined && typeof label.name === 'string') {
507+
label.name = localize(
508+
'notebookCellOutputLabel',
509+
"{0} • Cell {1} • Output {2}",
510+
label.name,
511+
`${cellIndex + 1}`,
512+
`${outputIndex + 1}`
513+
);
514+
} else if (cellIndex !== undefined && typeof label.name === 'string') {
515+
label.name = localize(
516+
'notebookCellOutputLabelSimple',
517+
"{0} • Cell {1} • Output",
518+
label.name,
519+
`${cellIndex + 1}`
520+
);
521+
}
520522
}
521523
}
522524

src/vs/workbench/services/notebook/common/notebookDocumentService.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,18 @@ export function extractCellOutputDetails(uri: URI): { notebook: URI; openIn: str
7979
const outputId = params.get('outputId') ?? undefined;
8080
const parsedCell = parse(uri.with({ scheme: Schemas.vscodeNotebookCell, query: null }));
8181
const outputIndex = params.get('outputIndex') ? parseInt(params.get('outputIndex') || '', 10) : undefined;
82-
83-
if (parsedCell?.notebook === undefined || parsedCell?.handle === undefined) {
84-
throw new Error('Invalid cell URI');
85-
}
82+
const notebookUri = parsedCell ? parsedCell.notebook : uri.with({
83+
scheme: params.get('notebookScheme') || Schemas.file,
84+
fragment: null,
85+
query: null,
86+
});
8687

8788
return {
88-
notebook: parsedCell.notebook,
89+
notebook: notebookUri,
8990
openIn: openIn,
9091
outputId: outputId,
9192
outputIndex: outputIndex,
92-
cellHandle: parsedCell.handle,
93+
cellHandle: parsedCell?.handle,
9394
cellFragment: uri.fragment,
9495
};
9596
}

0 commit comments

Comments
 (0)