Skip to content

Commit

Permalink
Fixes to exporting of plots to pdf (#16281)
Browse files Browse the repository at this point in the history
* Log and display errors when failing to export plot

* Include message

* Fixes to builds
  • Loading branch information
DonJayamanne authored Dec 10, 2024
1 parent fd909a4 commit 1706ffd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
14 changes: 9 additions & 5 deletions build/esbuild/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,15 @@ async function buildAll() {

.map(async (module) => {
const fullPath = require.resolve(module);
return build(fullPath, path.join(extensionFolder, 'dist', 'node_modules', `${module}.js`), {
target: 'desktop',
// These almost never change, easier to re-run copmilation if packges change.
watch: false
});
return build(
fullPath,
path.join(extensionFolder, 'dist', 'node_modules', `${path.join(module, 'index.js')}`),
{
target: 'desktop',
// These almost never change, easier to re-run copmilation if packges change.
watch: false
}
);
})
);
builders.push(
Expand Down
17 changes: 12 additions & 5 deletions src/webviews/extension-side/plotView/rendererCommunication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { IDisposable } from '../../../platform/common/types';
import { noop } from '../../../platform/common/utils/misc';
import { PlotViewHandler } from './plotViewHandler';
import { IPlotSaveHandler } from './types';
import { logger } from '../../../platform/logging';
import { DataScience } from '../../../platform/common/utils/localize';

export type OpenImageInPlotViewer = {
type: 'openImageInPlotViewer';
Expand Down Expand Up @@ -48,15 +50,20 @@ export class RendererCommunication implements IExtensionSyncActivationService, I
onDidReceiveMessage: Event<{ editor: NotebookEditor; message: OpenImageInPlotViewer | SaveImageAs }>;
};
api.onDidReceiveMessage(
({ editor, message }) => {
async ({ editor, message }) => {
const document = editor.notebook || window.activeNotebookEditor?.notebook;
if (!document) {
return;
}
if (message.type === 'saveImageAs') {
this.plotSaveHandler.savePlot(document, message.outputId, message.mimeType).catch(noop);
} else if (message.type === 'openImageInPlotViewer') {
this.plotViewHandler.openPlot(document, message.outputId).catch(noop);
try {
if (message.type === 'saveImageAs') {
await this.plotSaveHandler.savePlot(document, message.outputId, message.mimeType);
} else if (message.type === 'openImageInPlotViewer') {
await this.plotViewHandler.openPlot(document, message.outputId);
}
} catch (ex) {
logger.error(ex);
window.showErrorMessage(DataScience.exportImageFailed(ex.message)).then(noop, noop);
}
},
this,
Expand Down

0 comments on commit 1706ffd

Please sign in to comment.