summaryrefslogtreecommitdiff
path: root/src/term/cell.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-12-29 10:43:58 -0500
committerJoe Wilm <joe@jwilm.com>2016-12-29 10:43:58 -0500
commit115a4085b4806e289c23ab296585f2f22b42efb7 (patch)
tree89b365f8f85a59c2d8de1815a007b0fbd898f544 /src/term/cell.rs
parent0f1c742857b43565623932a5aa469ded2f1ad6dd (diff)
downloadalacritty-115a4085b4806e289c23ab296585f2f22b42efb7.tar.gz
alacritty-115a4085b4806e289c23ab296585f2f22b42efb7.zip
Fix selection copy for long lines
Long lines were previously broken at the terminal width. Now, a wrapping marker is kept on the final cell so that extra newlines are not inserted.
Diffstat (limited to 'src/term/cell.rs')
-rw-r--r--src/term/cell.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/term/cell.rs b/src/term/cell.rs
index a95875bf..db0cebcc 100644
--- a/src/term/cell.rs
+++ b/src/term/cell.rs
@@ -24,6 +24,7 @@ bitflags! {
const BOLD = 0b00000010,
const ITALIC = 0b00000100,
const UNDERLINE = 0b00001000,
+ const WRAPLINE = 0b00010000,
}
}
@@ -45,6 +46,10 @@ impl LineLength for grid::Row<Cell> {
fn line_length(&self) -> Column {
let mut length = Column(0);
+ if self[Column(self.len() - 1)].flags.contains(WRAPLINE) {
+ return Column(self.len());
+ }
+
for (index, cell) in self[..].iter().rev().enumerate() {
if cell.c != ' ' {
length = Column(self.len() - index);
@@ -105,4 +110,13 @@ mod tests {
assert_eq!(row.line_length(), Column(6));
}
+
+ #[test]
+ fn line_length_works_with_wrapline() {
+ let template = Cell::new(' ', Color::Indexed(0), Color::Indexed(0));
+ let mut row = Row::new(Column(10), &template);
+ row[Column(9)].flags.insert(super::WRAPLINE);
+
+ assert_eq!(row.line_length(), Column(10));
+ }
}