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.
This commit is contained in:
Daniel Imms
2020-11-10 08:16:05 -08:00
parent 3d61a39074
commit 3ab3514bd2

View File

@@ -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', () => {