提交 91f00c7c 编写于 作者: B Benjamin Pasero

web - allow to retry clipboard access (#112089)

上级 61995eab
......@@ -917,7 +917,7 @@ function registerOtherEditorCommands(): void {
nls.localize('enablePreview', "Preview editors have been enabled in settings.") :
nls.localize('disablePreview', "Preview editors have been disabled in settings."),
[{
label: nls.localize('learnMode', "Learn More"), run: () => openerService.open('https://go.microsoft.com/fwlink/?linkid=2147473')
label: nls.localize('learnMore', "Learn More"), run: () => openerService.open('https://go.microsoft.com/fwlink/?linkid=2147473')
}]
);
}
......
......@@ -188,7 +188,7 @@ export class NativeWindow extends Disposable {
// Shell Environment Issue Notifications
const choices: IPromptChoice[] = [{
label: localize('learnMode', "Learn More"),
label: localize('learnMore', "Learn More"),
run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2149667')
}];
......
......@@ -9,6 +9,8 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
import { BrowserClipboardService as BaseBrowserClipboardService } from 'vs/platform/clipboard/browser/clipboardService';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { once } from 'vs/base/common/functional';
import { DisposableStore } from 'vs/base/common/lifecycle';
export class BrowserClipboardService extends BaseBrowserClipboardService {
......@@ -27,22 +29,31 @@ export class BrowserClipboardService extends BaseBrowserClipboardService {
try {
return await navigator.clipboard.readText();
} catch (error) {
// Inform user about permissions problem
// (https://github.com/microsoft/vscode/issues/112089)
this.notificationService.prompt(
Severity.Error,
localize('clipboardError', "Unable to read from the browser's clipboard. Please make sure you have granted access for this website to read from the clipboard."),
[{
label: localize('learnMode', "Learn More"),
run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2151362')
}],
{
sticky: true
}
);
return '';
return new Promise<string>(resolve => {
// Inform user about permissions problem (https://github.com/microsoft/vscode/issues/112089)
const listener = new DisposableStore();
const handle = this.notificationService.prompt(
Severity.Error,
localize('clipboardError', "Unable to read from the browser's clipboard. Please make sure you have granted access for this website to read from the clipboard."),
[{
label: localize('retry', "Retry"),
run: async () => {
listener.dispose();
resolve(await this.readText(type));
}
}, {
label: localize('learnMore', "Learn More"),
run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2151362')
}],
{
sticky: true
}
);
// Always resolve the promise once the notification closes
listener.add(once(handle.onDidClose)(() => resolve('')));
});
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册