get the editor from the context for cases that its not the focused editor (#210962)

* get the editor from the context for cases that its not the focused editor

* remove blob retries
This commit is contained in:
Aaron Munger 2024-04-22 16:05:57 -07:00 committed by GitHub
parent dd168fb100
commit 23f9ce4a7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -33,9 +33,15 @@ registerAction2(class CopyCellOutputAction extends Action2 {
});
}
private getNoteboookEditor(editorService: IEditorService, outputContext: INotebookOutputActionContext | { outputViewModel: ICellOutputViewModel } | undefined): INotebookEditor | undefined {
if (outputContext && 'notebookEditor' in outputContext) {
return outputContext.notebookEditor;
}
return getNotebookEditorFromEditorPane(editorService.activeEditorPane);
}
async run(accessor: ServicesAccessor, outputContext: INotebookOutputActionContext | { outputViewModel: ICellOutputViewModel } | undefined): Promise<void> {
const editorService = accessor.get(IEditorService);
const notebookEditor = getNotebookEditorFromEditorPane(editorService.activeEditorPane);
const notebookEditor = this.getNoteboookEditor(accessor.get(IEditorService), outputContext);
if (!notebookEditor) {
return;

View file

@ -1576,7 +1576,7 @@ async function webviewPreloads(ctx: PreloadContext) {
// copyImage can be called from outside of the webview, which means this function may be running whilst the webview is gaining focus.
// Since navigator.clipboard.write requires the document to be focused, we need to wait for focus.
// We cannot use a listener, as there is a high chance the focus is gained during the setup of the listener resulting in us missing it.
setTimeout(() => { copyOutputImage(outputId, altOutputId, retries - 1); }, 20);
setTimeout(() => { copyOutputImage(outputId, altOutputId, retries - 1); }, 50);
return;
}