gui: round x-coordinate when selecting text

But don't round the y-coordinate as that one seems OK.

refs: https://github.com/wez/wezterm/issues/350
This commit is contained in:
Wez Furlong committed 2020-12-28 13:44:30 -08:00
1 parent c68bf92bcd
commit 94ca16d987
2 files changed
+9 -3

No files matched your search

+1
View File
@@ -35,6 +35,7 @@ brief notes about them may accumulate here.
* Windows: fix an issue where VNC-server-emulated AltGr was not treated as AltGr [#392](https://github.com/wez/wezterm/issues/392)
* X11: fix an issue where keys that produce unicode characters retained SHIFT as a modifier instead of normalizing it away. [#394](https://github.com/wez/wezterm/issues/394)
* Fixed an issue where a symbol-only font would be seen as 0-width and panic wezterm [#404](https://github.com/wez/wezterm/issues/404)
* Tweaked mouse selection: we now round the x-coordinate to the nearest cell which makes it a bit more forgiving if the mouse cursor is slightly to the left of the intended cell start. [#350](https://github.com/wez/wezterm/issues/350)
### 20201101-103216-403d002d
+8 -3
View File
@@ -332,12 +332,17 @@ impl WindowCallbacks for TermWindow {
};
let config = configuration();
let x = (event
// Round the x coordinate so that we're a bit more forgiving of
// the horizontal position when selecting cells
let x = ((event
.coords
.x
.sub(config.window_padding.left as isize)
.max(0)
/ self.render_metrics.cell_size.width) as usize;
.max(0) as f32)
/ self.render_metrics.cell_size.width as f32)
.round()
.trunc() as usize;
// But don't round the y coordinate as that is more annoying
let y = (event
.coords
.y