mirror of
https://github.com/microsoft/vscode.git
synced 2026-10-01 11:32:08 +01:00
Separate Copy and Paste feature detection.
This commit is contained in:
@@ -4,16 +4,22 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
|
||||
/**
|
||||
* Browser feature we can support in current platform, browser and environment.
|
||||
*/
|
||||
export const BrowserFeatures = {
|
||||
clipboard: {
|
||||
access: !!(navigator
|
||||
&& navigator.clipboard
|
||||
&& navigator.clipboard.readText
|
||||
&& navigator.clipboard.writeText),
|
||||
writeText: (
|
||||
platform.isNative
|
||||
|| document.queryCommandSupported('copy')
|
||||
|| !!(navigator && navigator.clipboard && navigator.clipboard.writeText)
|
||||
),
|
||||
readText: (
|
||||
platform.isNative
|
||||
|| !!(navigator && navigator.clipboard && navigator.clipboard.readText)
|
||||
),
|
||||
richText: (() => {
|
||||
if (browser.isIE) {
|
||||
return false;
|
||||
|
||||
@@ -553,12 +553,13 @@ actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FindPrevious, Fi
|
||||
}, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED), 'Terminal: Find previous', category);
|
||||
|
||||
// Commands miht be affected by Web restrictons
|
||||
if (BrowserFeatures.clipboard.access) {
|
||||
if (BrowserFeatures.clipboard.writeText) {
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(CopyTerminalSelectionAction, CopyTerminalSelectionAction.ID, CopyTerminalSelectionAction.LABEL, {
|
||||
primary: KeyMod.CtrlCmd | KeyCode.KEY_C,
|
||||
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_C }
|
||||
}, ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, KEYBINDING_CONTEXT_TERMINAL_FOCUS)), 'Terminal: Copy Selection', category);
|
||||
|
||||
}
|
||||
if (BrowserFeatures.clipboard.readText) {
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(TerminalPasteAction, TerminalPasteAction.ID, TerminalPasteAction.LABEL, {
|
||||
primary: KeyMod.CtrlCmd | KeyCode.KEY_V,
|
||||
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_V }
|
||||
|
||||
@@ -144,8 +144,10 @@ export class TerminalPanel extends Panel {
|
||||
this._copyContextMenuAction = this._instantiationService.createInstance(CopyTerminalSelectionAction, CopyTerminalSelectionAction.ID, CopyTerminalSelectionAction.SHORT_LABEL);
|
||||
|
||||
const clipboardActions = [];
|
||||
if (BrowserFeatures.clipboard.access) {
|
||||
if (BrowserFeatures.clipboard.writeText) {
|
||||
clipboardActions.push(this._copyContextMenuAction);
|
||||
}
|
||||
if (BrowserFeatures.clipboard.readText) {
|
||||
clipboardActions.push(this._instantiationService.createInstance(TerminalPasteAction, TerminalPasteAction.ID, TerminalPasteAction.SHORT_LABEL));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user