-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SR command to read last REPL execution
- Loading branch information
Showing
13 changed files
with
139 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
src/vs/workbench/contrib/notebook/browser/notebookAccessibility.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/vs/workbench/contrib/notebook/browser/viewModel/outputHelper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { NotebookTextModel } from '../../common/model/notebookTextModel.js'; | ||
import { ICellViewModel } from '../notebookBrowser.js'; | ||
|
||
export function getOutputText(notebook: NotebookTextModel, viewCell: ICellViewModel): string { | ||
let outputContent = ''; | ||
const decoder = new TextDecoder(); | ||
for (let i = 0; i < viewCell.outputsViewModels.length; i++) { | ||
const outputViewModel = viewCell.outputsViewModels[i]; | ||
const outputTextModel = viewCell.model.outputs[i]; | ||
const [mimeTypes, pick] = outputViewModel.resolveMimeTypes(notebook, undefined); | ||
const mimeType = mimeTypes[pick].mimeType; | ||
let buffer = outputTextModel.outputs.find(output => output.mime === mimeType); | ||
|
||
if (!buffer || mimeType.startsWith('image')) { | ||
buffer = outputTextModel.outputs.find(output => !output.mime.startsWith('image')); | ||
} | ||
|
||
let text = `${mimeType}`; // default in case we can't get the text value for some reason. | ||
if (buffer) { | ||
const charLimit = 100_000; | ||
text = decoder.decode(buffer.data.slice(0, charLimit).buffer); | ||
|
||
if (buffer.data.byteLength > charLimit) { | ||
text = text + '...(truncated)'; | ||
} | ||
|
||
if (mimeType.endsWith('error')) { | ||
text = text.replace(/\\u001b\[[0-9;]*m/gi, '').replaceAll('\\n', '\n'); | ||
} | ||
} | ||
|
||
const index = viewCell.outputsViewModels.length > 1 | ||
? `Cell output ${i + 1} of ${viewCell.outputsViewModels.length}\n` | ||
: ''; | ||
outputContent = outputContent.concat(`${index}${text}\n`); | ||
} | ||
return outputContent.trim(); | ||
} | ||
|
||
export const TEXT_BASED_MIMETYPES = [ | ||
'text/latex', | ||
'text/html', | ||
'application/vnd.code.notebook.error', | ||
'application/vnd.code.notebook.stdout', | ||
'application/x.notebook.stdout', | ||
'application/x.notebook.stream', | ||
'application/vnd.code.notebook.stderr', | ||
'application/x.notebook.stderr', | ||
'text/plain', | ||
'text/markdown', | ||
'application/json' | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters