Fix column selection issues

The following parts were not respecting the column selection edge case where the
start column was greater than the end column while the start row was less than the
end row:

- Webgl renderer
- DOM renderer
- Selection service (ie. getSelection(), I don't think this was a
  regression)

Fixes #3855
This commit is contained in:
Daniel Imms
2022-06-14 06:51:54 -07:00
parent fe99422ca4
commit efb939d171
4 changed files with 19 additions and 6 deletions
+2 -1
View File
@@ -304,8 +304,9 @@ export class DomRenderer extends Disposable implements IRenderer {
const documentFragment = document.createDocumentFragment();
if (columnSelectMode) {
const isXFlipped = start[0] > end[0];
documentFragment.appendChild(
this._createSelectionElement(viewportCappedStartRow, start[0], end[0], viewportCappedEndRow - viewportCappedStartRow + 1)
this._createSelectionElement(viewportCappedStartRow, isXFlipped ? end[0] : start[0], isXFlipped ? start[0] : end[0], viewportCappedEndRow - viewportCappedStartRow + 1)
);
} else {
// Draw first row
@@ -322,8 +322,12 @@ export class DomRendererRowFactory {
return false;
}
if (this._columnSelectMode) {
return x >= start[0] && y >= start[1] &&
x < end[0] && y < end[1];
if (start[0] <= end[0]) {
return x >= start[0] && y >= start[1] &&
x < end[0] && y <= end[1];
}
return x < start[0] && y >= start[1] &&
x >= end[0] && y <= end[1];
}
return (y > start[1] && y < end[1]) ||
(start[1] === end[1] && y === start[1] && x >= start[0] && x < end[0]) ||