Skip to content

Commit

Permalink
Get correct col/row coords from mouse event
Browse files Browse the repository at this point in the history
Before the y from getCoords could be -1, a ceil call was also causing
a single pixel offset in each dimension

Related microsoft/vscode#50128
  • Loading branch information
Tyriar committed Sep 30, 2018
1 parent 990bf5c commit 4f5f6e1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/MouseHelper.ts
Expand Up @@ -32,7 +32,7 @@ export class MouseHelper {
y += element.scrollTop;
element = <HTMLElement>element.parentElement;
}
return [x, y];
return [x, y + 1];
}

/**
Expand All @@ -59,8 +59,8 @@ export class MouseHelper {
return null;
}

coords[0] = Math.ceil((coords[0] + (isSelection ? this._renderer.dimensions.actualCellWidth / 2 : 0)) / this._renderer.dimensions.actualCellWidth);
coords[1] = Math.ceil(coords[1] / this._renderer.dimensions.actualCellHeight);
coords[0] = Math.floor((coords[0] + (isSelection ? this._renderer.dimensions.actualCellWidth / 2 : 0)) / this._renderer.dimensions.actualCellWidth) + 1;
coords[1] = Math.floor(coords[1] / this._renderer.dimensions.actualCellHeight) + 1;

// Ensure coordinates are within the terminal viewport. Note that selections
// need an addition point of precision to cover the end point (as characters
Expand Down

0 comments on commit 4f5f6e1

Please sign in to comment.