1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Fix unclickable URLs with scrolled viewport

Since scrolling the terminal moves around the underlying data structure
of the terminal, the URL selection would search for the URL at the
position where the click would have been without any scrolling.

By adding the viewport offset to the click position, the URL clicking
now searches at the correct location.

This fixes https://github.com/jwilm/alacritty/issues/2076.
This commit is contained in:
Christian Duerr 2019-02-07 00:55:18 +00:00 committed by GitHub
parent a7a6bf53d4
commit e561ae3733
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View file

@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Allow disabling URL launching by setting the value of `mouse.url.launcher` to `None` - Allow disabling URL launching by setting the value of `mouse.url.launcher` to `None`
- Corrected the `window.decorations` config documentation for macOS - Corrected the `window.decorations` config documentation for macOS
- Fix IME position on HiDPI displays - Fix IME position on HiDPI displays
- URLs not opening while terminal is scrolled
## Version 0.2.7 ## Version 0.2.7

View file

@ -465,6 +465,11 @@ impl<T> Grid<T> {
pub fn contains(&self, point: &Point) -> bool { pub fn contains(&self, point: &Point) -> bool {
self.lines > point.line && self.cols > point.col self.lines > point.line && self.cols > point.col
} }
#[inline]
pub fn display_offset(&self) -> usize {
self.display_offset
}
} }
impl<'a, T> Iterator for GridIterator<'a, T> { impl<'a, T> Iterator for GridIterator<'a, T> {

View file

@ -97,10 +97,11 @@ impl Search for Term {
} }
fn url_search(&self, mut point: Point<usize>) -> Option<String> { fn url_search(&self, mut point: Point<usize>) -> Option<String> {
// Switch first line from top to bottom
point.line = self.grid.num_lines().0 - point.line - 1; point.line = self.grid.num_lines().0 - point.line - 1;
// Limit the starting point to the last line in the history // Remove viewport scroll offset
point.line = min(point.line, self.grid.len() - 1); point.line += self.grid.display_offset();
// Create forwards and backwards iterators // Create forwards and backwards iterators
let iterf = self.grid.iter_from(point); let iterf = self.grid.iter_from(point);