From 3ab3514bd2d134fef500cc6fe0ec5e564fe31a68 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 10 Nov 2020 08:16:05 -0800 Subject: [PATCH] Force ctrl+v to not be sent to shell in Firefox Paste wasn't working in Firefox or other browsers not supporting navigator.clipboard.readText because xterm.js would process the keystroke, send it over to the shell and prevent the default (paste) from occurring. This change Forces ctrl+v to be ignored by xterm.js' keyboard event processing for such browsers, the keybinding won't be customizable but this seems to be the only way. --- .../workbench/contrib/terminal/browser/terminalInstance.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 9857b3dca40..8d0626e5406 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -45,6 +45,7 @@ import { EnvironmentVariableInfoWidget } from 'vs/workbench/contrib/terminal/bro import { IEnvironmentVariableInfo } from 'vs/workbench/contrib/terminal/common/environmentVariable'; import { TerminalLaunchHelpAction } from 'vs/workbench/contrib/terminal/browser/terminalActions'; import { TypeAheadAddon } from 'vs/workbench/contrib/terminal/browser/terminalTypeAheadAddon'; +import { BrowserFeatures } from 'vs/base/browser/canIUse'; // How long in milliseconds should an average frame take to render for a notification to appear // which suggests the fallback DOM-based renderer @@ -564,6 +565,12 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { return false; } + // Fallback to force ctrl+v to paste on browsers that do not support + // navigator.clipboard.readText + if (!BrowserFeatures.clipboard.readText && event.key === 'v' && event.ctrlKey) { + return false; + } + return true; }); this._register(dom.addDisposableListener(xterm.element, 'mousedown', () => {