Merge pull request #1784 from xtermjs/Tyriar-patch-1
Fixing isClickInSelection to cover missing cases
This commit is contained in:
@@ -30,6 +30,7 @@ class TestSelectionManager extends SelectionManager {
|
|||||||
|
|
||||||
public selectLineAt(line: number): void { this._selectLineAt(line); }
|
public selectLineAt(line: number): void { this._selectLineAt(line); }
|
||||||
public selectWordAt(coords: [number, number]): void { this._selectWordAt(coords, true); }
|
public selectWordAt(coords: [number, number]): void { this._selectWordAt(coords, true); }
|
||||||
|
public areCoordsInSelection(coords: [number, number], start: [number, number], end: [number, number]): boolean { return this._areCoordsInSelection(coords, start, end); }
|
||||||
|
|
||||||
// Disable DOM interaction
|
// Disable DOM interaction
|
||||||
public enable(): void {}
|
public enable(): void {}
|
||||||
@@ -478,5 +479,17 @@ describe('SelectionManager', () => {
|
|||||||
assert.equal(selectionManager.selectionText, 'a\n😁\nc');
|
assert.equal(selectionManager.selectionText, 'a\n😁\nc');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('_areCoordsInSelection', () => {
|
||||||
|
it('should return whether coords are in the selection', () => {
|
||||||
|
assert.isFalse(selectionManager.areCoordsInSelection([0, 0], [2, 0], [2, 1]));
|
||||||
|
assert.isFalse(selectionManager.areCoordsInSelection([1, 0], [2, 0], [2, 1]));
|
||||||
|
assert.isTrue(selectionManager.areCoordsInSelection([2, 0], [2, 0], [2, 1]));
|
||||||
|
assert.isTrue(selectionManager.areCoordsInSelection([10, 0], [2, 0], [2, 1]));
|
||||||
|
assert.isTrue(selectionManager.areCoordsInSelection([0, 1], [2, 0], [2, 1]));
|
||||||
|
assert.isTrue(selectionManager.areCoordsInSelection([1, 1], [2, 0], [2, 1]));
|
||||||
|
assert.isFalse(selectionManager.areCoordsInSelection([2, 1], [2, 0], [2, 1]));
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -289,9 +289,14 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this._areCoordsInSelection(coords, start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected _areCoordsInSelection(coords: [number, number], start: [number, number], end: [number, number]): boolean {
|
||||||
return (coords[1] > start[1] && coords[1] < end[1]) ||
|
return (coords[1] > start[1] && coords[1] < end[1]) ||
|
||||||
(start[1] === end[1] && coords[1] === start[1] && coords[0] > start[0] && coords[0] < end[0]) ||
|
(start[1] === end[1] && coords[1] === start[1] && coords[0] >= start[0] && coords[0] < end[0]) ||
|
||||||
(start[1] < end[1] && coords[1] === end[1] && coords[0] < end[0]);
|
(start[1] < end[1] && coords[1] === end[1] && coords[0] < end[0]) ||
|
||||||
|
(start[1] < end[1] && coords[1] === start[1] && coords[0] >= start[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user