From da9b4b1a692590e2f4f3eb738108fe8832342c6d Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 11 Jul 2019 09:34:45 -0700 Subject: [PATCH 1/2] Don't trigger selection when mouse events are on Fixes #2301 --- src/Terminal.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Terminal.ts b/src/Terminal.ts index 1e51f439..c625114b 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -644,6 +644,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp } else { this._selectionService.enable(); } + this._inputHandler.setBrowserServices(this._selectionService); if (this.options.screenReaderMode) { // Note that this must be done *after* the renderer is created in order to From 7a37bd880e4f0df1d3213fcbf54c8b78ddf07349 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 11 Jul 2019 11:04:11 -0700 Subject: [PATCH 2/2] Add test for mouse events --- test/api/InputHandler.api.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/api/InputHandler.api.ts b/test/api/InputHandler.api.ts index d9c9bf89..dfd16ddb 100644 --- a/test/api/InputHandler.api.ts +++ b/test/api/InputHandler.api.ts @@ -232,6 +232,31 @@ describe('InputHandler Integration Tests', function(): void { describe('SM: Set Mode', () => { describe('CSI ? Pm h', () => { + it('Pm = 1003, Set Use All Motion (any event) Mouse Tracking', async() => { + const coords = await page.evaluate(` + (function() { + const rect = window.term.element.getBoundingClientRect(); + return {left: rect.left, top: rect.top, bottom: rect.bottom, right: rect.right}; + })(); + `); + // Click and drag and ensure there is a selection + await page.mouse.click((coords.left + coords.right) / 2, (coords.top + coords.bottom) / 2); + await page.mouse.down(); + await page.mouse.move((coords.left + coords.right) / 2, (coords.top + coords.bottom) / 4); + assert.ok(await page.evaluate(`window.term.getSelection().length`) > 0, 'mouse events are off so there should be a selection'); + await page.mouse.up(); + // Clear selection + await page.mouse.click((coords.left + coords.right) / 2, (coords.top + coords.bottom) / 2); + assert.equal(await page.evaluate(`window.term.getSelection().length`), 0); + // Enable mouse events + await page.evaluate(`window.term.write('\x1b[?1003h')`); + // Click and drag and ensure there is no selection + await page.mouse.click((coords.left + coords.right) / 2, (coords.top + coords.bottom) / 2); + await page.mouse.down(); + await page.mouse.move((coords.left + coords.right) / 2, (coords.top + coords.bottom) / 4); + assert.equal(await page.evaluate(`window.term.getSelection().length`), 0, 'mouse events are on so there should be no selection'); + await page.mouse.up(); + }); it('Pm = 2004, Set bracketed paste mode', async function(): Promise { assert.equal(await simulatePaste('foo'), 'foo'); await page.evaluate(`window.term.write('\x1b[?2004h')`);