mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-27 02:48:34 +00:00
Fix incorrect placement of terminal selection when dragging
Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
0c4e2ef419
commit
61db60b3e2
1 changed files with 4 additions and 6 deletions
|
@ -162,22 +162,20 @@ pub fn mouse_side(
|
||||||
pos: Point<Pixels>,
|
pos: Point<Pixels>,
|
||||||
cur_size: TerminalSize,
|
cur_size: TerminalSize,
|
||||||
) -> alacritty_terminal::index::Direction {
|
) -> alacritty_terminal::index::Direction {
|
||||||
let cell_width = cur_size.cell_width.floor();
|
let cell_width = cur_size.cell_width;
|
||||||
if cell_width == px(0.) {
|
if cell_width == px(0.) {
|
||||||
return Side::Right;
|
return Side::Right;
|
||||||
}
|
}
|
||||||
|
|
||||||
let x = pos.x.floor();
|
let cell_x = cmp::max(px(0.), pos.x) % cell_width;
|
||||||
|
let half_cell_width = cur_size.cell_width / 2.0;
|
||||||
let cell_x = cmp::max(px(0.), x - cell_width) % cell_width;
|
|
||||||
let half_cell_width = (cur_size.cell_width / 2.0).floor();
|
|
||||||
let additional_padding = (cur_size.width() - cur_size.cell_width * 2.) % cur_size.cell_width;
|
let additional_padding = (cur_size.width() - cur_size.cell_width * 2.) % cur_size.cell_width;
|
||||||
let end_of_grid = cur_size.width() - cur_size.cell_width - additional_padding;
|
let end_of_grid = cur_size.width() - cur_size.cell_width - additional_padding;
|
||||||
|
|
||||||
//Width: Pixels or columns?
|
//Width: Pixels or columns?
|
||||||
if cell_x > half_cell_width
|
if cell_x > half_cell_width
|
||||||
// Edge case when mouse leaves the window.
|
// Edge case when mouse leaves the window.
|
||||||
|| x >= end_of_grid
|
|| pos.x >= end_of_grid
|
||||||
{
|
{
|
||||||
Side::Right
|
Side::Right
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue