Skip to content

Davidkutu/ds scrapbook render fix #9912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@

### Fixes

1. Removed unnecessary warning when executing cells that use Scrapbook,
Fix an html crash when using not supported mime types
([#9796](https://github.com/microsoft/vscode-python/issues/9796))
1. Fixed the focus on the interactive window when pressing ctrl + 1/ ctrl + 2
([#9693](https://github.com/microsoft/vscode-python/issues/9693))
1. Fix variable explorer in Interactive and Notebook editors from interfering with execution.
Expand Down
7 changes: 5 additions & 2 deletions src/datascience-ui/interactive-common/cellOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ImageButton } from '../react-common/imageButton';
import { getLocString } from '../react-common/locReactSide';
import { fixLatexEquations } from './latexManipulation';
import { ICellViewModel } from './mainState';
import { getRichestMimetype, getTransform } from './transforms';
import { getRichestMimetype, getTransform, isMimeTypeSupported } from './transforms';

// tslint:disable-next-line: no-var-requires no-require-imports
const ansiToHtml = require('ansi-to-html');
Expand Down Expand Up @@ -380,7 +380,7 @@ export class CellOutput extends React.Component<ICellOutputProps> {
let mimetype = transformed.mimeType;

// If that worked, use the transform
if (mimetype) {
if (mimetype && isMimeTypeSupported(mimetype)) {
// Get the matching React.Component for that mimetype
const Transform = getTransform(mimetype);

Expand All @@ -405,6 +405,9 @@ export class CellOutput extends React.Component<ICellOutputProps> {
</div>
);
}
} else if (mimetype.startsWith('application/scrapbook.scrap.')) {
// Silently skip rendering of these mime types, render an empty div so the user sees the cell was executed.
buffer.push(<div key={index}></div>);
} else {
if (transformed.data) {
const keys = Object.keys(transformed.data);
Expand Down
5 changes: 5 additions & 0 deletions src/datascience-ui/interactive-common/transforms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,8 @@ export async function forceLoad() {
// Used for tests to make sure we don't end up with 'Loading ...' anywhere in a test
await Promise.all(mimeTypeToImport.map(m => m.getComponent()));
}

export function isMimeTypeSupported(mimeType: string): Boolean {
const match = mimeTypeToImport.find(m => m.mimeType === mimeType);
return match ? true : false;
}