aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2019-03-19 22:32:40 +0000
committerGitHub <noreply@github.com>2019-03-19 22:32:40 +0000
commitc6ab2a8867ad0d064d67dc5e32138cbb3d3ab833 (patch)
treeab6a518b80e008215a3d51871b6d71ac3b487852
parenta672f7d553ac17d5aaef8dc667dee31d5815677d (diff)
downloadalacritty-c6ab2a8867ad0d064d67dc5e32138cbb3d3ab833.tar.gz
alacritty-c6ab2a8867ad0d064d67dc5e32138cbb3d3ab833.zip
Fix URLs getting incorrectly extended to next line
If a URL ends right at the end of the terminal, it would sometimes incorrectly include the characters from the following line when launching the URL. Similar to the semantic search function, the URL parsing iterator will now stop if it encounters a cell at the end of the line which does not contain the `WRAPLINE` flag. This fixes #1906.
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/term/mod.rs17
2 files changed, 13 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index daf1fa83..db79262d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The AltGr key no longer sends escapes (like Alt)
- Fixes increase/decrease font-size keybindings on international keyboards
- On Wayland, the `--title` flag will set the Window title now
+- Parsing issues with URLs starting in the first or ending in the last column
## Version 0.2.9
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 09f45721..a99098bd 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -85,7 +85,7 @@ impl Search for Term {
point.line = min(point.line, self.grid.len() - 1);
let mut iter = self.grid.iter_from(point);
- let last_col = self.grid.num_cols() - Column(1);
+ let last_col = self.grid.num_cols() - 1;
while let Some(cell) = iter.next() {
if self.semantic_escape_chars.contains(cell.c) {
@@ -103,6 +103,8 @@ impl Search for Term {
}
fn url_search(&self, mut point: Point<usize>) -> Option<Url> {
+ let last_col = self.grid.num_cols() - 1;
+
// Switch first line from top to bottom
point.line = self.grid.num_lines().0 - point.line - 1;
@@ -110,19 +112,24 @@ impl Search for Term {
point.line += self.grid.display_offset();
// Create forwards and backwards iterators
- let iterf = self.grid.iter_from(point);
+ let mut iterf = self.grid.iter_from(point);
point.col += 1;
let mut iterb = self.grid.iter_from(point);
// Find URLs
let mut url_parser = UrlParser::new();
while let Some(cell) = iterb.prev() {
- if url_parser.advance_left(cell.c) {
+ if (iterb.cur().col == last_col && !cell.flags.contains(cell::Flags::WRAPLINE))
+ || url_parser.advance_left(cell.c)
+ {
break;
}
}
- for cell in iterf {
- if url_parser.advance_right(cell.c) {
+
+ while let Some(cell) = iterf.next() {
+ if url_parser.advance_right(cell.c)
+ || (iterf.cur().col == last_col && !cell.flags.contains(cell::Flags::WRAPLINE))
+ {
break;
}
}