提交 38f4b138 编写于 作者: D Daniel Imms

Fix selection drop on keyup due to xterm.js

上级 5abb5304
......@@ -122,7 +122,8 @@ export class TerminalInstance implements ITerminalInstance {
return false;
});
this._xterm.attachCustomKeydownHandler((event: KeyboardEvent) => {
// Skip processing by xterm.js of commands within commandsToSkipShell
// Skip processing by xterm.js of keyboard events that resolve to commands described
// within commandsToSkipShell
const standardKeyboardEvent = new StandardKeyboardEvent(event);
const keybinding = new Keybinding(standardKeyboardEvent.asKeybinding());
const resolveResult = this._keybindingService.resolve(keybinding, standardKeyboardEvent.target);
......@@ -140,8 +141,16 @@ export class TerminalInstance implements ITerminalInstance {
// Wait until mouseup has propogated through the DOM before evaluating the new selection
// state.
setTimeout(() => {
this._terminalHasTextContextKey.set(!window.getSelection().isCollapsed);
console.log('Has text: ' + !window.getSelection().isCollapsed);
this._refreshSelectionContextKey();
}, 0);
});
// xterm.js currently drops selection on keyup as we need to handle this case.
(<HTMLElement>this._xterm.element).addEventListener('keyup', event => {
// Wait until keyup has propogated through the DOM before evaluating the new selection
// state.
setTimeout(() => {
this._refreshSelectionContextKey();
}, 0);
});
......@@ -277,6 +286,10 @@ export class TerminalInstance implements ITerminalInstance {
this._xterm.clear();
}
private _refreshSelectionContextKey() {
this._terminalHasTextContextKey.set(!window.getSelection().isCollapsed);
}
private sanitizeInput(data: any) {
return typeof data === 'string' ? data.replace(TerminalInstance.EOL_REGEX, os.EOL) : data;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册