Fix #83595. Bring back copy paste from keyboard in Firefox and Safari.
This commit is contained in:
parent
46aaf80c17
commit
fe59391214
4 changed files with 39 additions and 13 deletions
|
@ -125,7 +125,19 @@ export const isIPad = (userAgent.indexOf('iPad') >= 0);
|
|||
export const isEdgeWebView = isEdge && (userAgent.indexOf('WebView/') >= 0);
|
||||
export const isStandalone = (window.matchMedia && window.matchMedia('(display-mode: standalone)').matches);
|
||||
|
||||
export function hasClipboardSupport() {
|
||||
export function clipboardAccessAllowed() {
|
||||
if (!navigator.clipboard) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!navigator.clipboard.readText || !navigator.clipboard.writeText) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function hasRichTextClipboardSupport() {
|
||||
if (isIE) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -533,7 +533,7 @@ export class TextAreaInput extends Disposable {
|
|||
}
|
||||
|
||||
private _ensureClipboardGetsEditorSelection(e: ClipboardEvent): void {
|
||||
const dataToCopy = this._host.getDataToCopy(ClipboardEventUtils.canUseTextData(e) && browser.hasClipboardSupport());
|
||||
const dataToCopy = this._host.getDataToCopy(ClipboardEventUtils.canUseTextData(e) && browser.hasRichTextClipboardSupport());
|
||||
const storedMetadata: ClipboardStoredMetadata = {
|
||||
version: 1,
|
||||
isFromEmptySelection: dataToCopy.isFromEmptySelection,
|
||||
|
|
|
@ -35,6 +35,7 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
|||
import { registerShellConfiguration } from 'vs/workbench/contrib/terminal/common/terminalShellConfig';
|
||||
import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { clipboardAccessAllowed } from 'vs/base/browser/browser';
|
||||
|
||||
registerSingleton(ITerminalService, TerminalService, true);
|
||||
|
||||
|
@ -344,10 +345,6 @@ Registry.as<panel.PanelRegistry>(panel.Extensions.Panels).setDefaultPanelId(TERM
|
|||
const category = TERMINAL_ACTION_CATEGORY;
|
||||
const actionRegistry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(KillTerminalAction, KillTerminalAction.ID, KillTerminalAction.LABEL), 'Terminal: Kill the Active Terminal Instance', category);
|
||||
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);
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(CreateNewTerminalAction, CreateNewTerminalAction.ID, CreateNewTerminalAction.LABEL, {
|
||||
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKTICK,
|
||||
mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.US_BACKTICK }
|
||||
|
@ -360,10 +357,6 @@ actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(CreateNewInActiv
|
|||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusActiveTerminalAction, FocusActiveTerminalAction.ID, FocusActiveTerminalAction.LABEL), 'Terminal: Focus Terminal', category);
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusNextTerminalAction, FocusNextTerminalAction.ID, FocusNextTerminalAction.LABEL), 'Terminal: Focus Next Terminal', category);
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusPreviousTerminalAction, FocusPreviousTerminalAction.ID, FocusPreviousTerminalAction.LABEL), 'Terminal: Focus Previous Terminal', category);
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(TerminalPasteAction, TerminalPasteAction.ID, TerminalPasteAction.LABEL, {
|
||||
primary: KeyMod.CtrlCmd | KeyCode.KEY_V,
|
||||
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_V }
|
||||
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Paste into Active Terminal', category);
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectAllTerminalAction, SelectAllTerminalAction.ID, SelectAllTerminalAction.LABEL, {
|
||||
// Don't use ctrl+a by default as that would override the common go to start
|
||||
// of prompt shell binding
|
||||
|
@ -559,6 +552,19 @@ actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FindPrevious, Fi
|
|||
mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G, secondary: [KeyMod.Shift | KeyCode.F3, KeyCode.Enter] },
|
||||
}, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED), 'Terminal: Find previous', category);
|
||||
|
||||
// Commands miht be affected by Web restrictons
|
||||
if (clipboardAccessAllowed()) {
|
||||
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);
|
||||
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(TerminalPasteAction, TerminalPasteAction.ID, TerminalPasteAction.LABEL, {
|
||||
primary: KeyMod.CtrlCmd | KeyCode.KEY_V,
|
||||
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_V }
|
||||
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Paste into Active Terminal', category);
|
||||
}
|
||||
|
||||
(new SendSequenceTerminalCommand({
|
||||
id: SendSequenceTerminalCommand.ID,
|
||||
precondition: undefined,
|
||||
|
|
|
@ -26,6 +26,7 @@ import { INotificationService, IPromptChoice, Severity } from 'vs/platform/notif
|
|||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { assertIsDefined } from 'vs/base/common/types';
|
||||
import { clipboardAccessAllowed } from 'vs/base/browser/browser';
|
||||
|
||||
const FIND_FOCUS_CLASS = 'find-focused';
|
||||
|
||||
|
@ -141,13 +142,20 @@ export class TerminalPanel extends Panel {
|
|||
private _getContextMenuActions(): IAction[] {
|
||||
if (!this._contextMenuActions || !this._copyContextMenuAction) {
|
||||
this._copyContextMenuAction = this._instantiationService.createInstance(CopyTerminalSelectionAction, CopyTerminalSelectionAction.ID, CopyTerminalSelectionAction.SHORT_LABEL);
|
||||
|
||||
const clipboardActions = [];
|
||||
if (clipboardAccessAllowed()) {
|
||||
clipboardActions.push(this._copyContextMenuAction);
|
||||
clipboardActions.push(this._instantiationService.createInstance(TerminalPasteAction, TerminalPasteAction.ID, TerminalPasteAction.SHORT_LABEL));
|
||||
}
|
||||
|
||||
clipboardActions.push(this._instantiationService.createInstance(SelectAllTerminalAction, SelectAllTerminalAction.ID, SelectAllTerminalAction.LABEL));
|
||||
|
||||
this._contextMenuActions = [
|
||||
this._instantiationService.createInstance(CreateNewTerminalAction, CreateNewTerminalAction.ID, CreateNewTerminalAction.SHORT_LABEL),
|
||||
this._instantiationService.createInstance(SplitTerminalAction, SplitTerminalAction.ID, SplitTerminalAction.SHORT_LABEL),
|
||||
new Separator(),
|
||||
this._copyContextMenuAction,
|
||||
this._instantiationService.createInstance(TerminalPasteAction, TerminalPasteAction.ID, TerminalPasteAction.SHORT_LABEL),
|
||||
this._instantiationService.createInstance(SelectAllTerminalAction, SelectAllTerminalAction.ID, SelectAllTerminalAction.LABEL),
|
||||
...clipboardActions,
|
||||
new Separator(),
|
||||
this._instantiationService.createInstance(ClearTerminalAction, ClearTerminalAction.ID, ClearTerminalAction.LABEL),
|
||||
new Separator(),
|
||||
|
|
Loading…
Reference in a new issue