Skip to content

Commit

Permalink
Merge pull request #2302 from Tyriar/2301_mouse_events
Browse files Browse the repository at this point in the history
Don't trigger selection when mouse events are on
  • Loading branch information
Tyriar committed Jul 11, 2019
2 parents a9961c8 + 7a37bd8 commit e99de7a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions test/api/InputHandler.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
assert.equal(await simulatePaste('foo'), 'foo');
await page.evaluate(`window.term.write('\x1b[?2004h')`);
Expand Down

0 comments on commit e99de7a

Please sign in to comment.