summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-08-12 08:36:24 +0000
committerGitHub <noreply@github.com>2020-08-12 08:36:24 +0000
commit96ea5c445ecc25a5b2d400b11f0ff843e9cbdd7a (patch)
tree767f7eb547514a661bf8307c995fd1e5fd415e3a /alacritty_terminal/src
parent424791842ff1a353b4b8f02daf1acb93d4ebceef (diff)
downloadalacritty-96ea5c445ecc25a5b2d400b11f0ff843e9cbdd7a.tar.gz
alacritty-96ea5c445ecc25a5b2d400b11f0ff843e9cbdd7a.zip
Fix handling of wrapline flag in last line
This resolves an issue where Alacritty would crash when a wrapline flag was present in the last column of the last line. While it should not be possible to achieve this with normal text flow, it is possible to rotate the content downwards using the `CSI Ps T` escape, causing this bug to occur. This also works around other issues like the vi cursor jumping to the top of the screen when trying to move beyond the last column using the `l` key. In debug mode this even lead to a crash due to the overflow. Fixes #4109.
Diffstat (limited to 'alacritty_terminal/src')
-rw-r--r--alacritty_terminal/src/term/search.rs4
-rw-r--r--alacritty_terminal/src/vi_mode.rs2
2 files changed, 4 insertions, 2 deletions
diff --git a/alacritty_terminal/src/term/search.rs b/alacritty_terminal/src/term/search.rs
index a6664054..e9c55f1c 100644
--- a/alacritty_terminal/src/term/search.rs
+++ b/alacritty_terminal/src/term/search.rs
@@ -420,7 +420,9 @@ impl<T> Term<T> {
/// Find the end of the current line across linewraps.
pub fn line_search_right(&self, mut point: Point<usize>) -> Point<usize> {
- while self.grid[point.line][self.cols() - 1].flags.contains(Flags::WRAPLINE) {
+ while point.line > 0
+ && self.grid[point.line][self.cols() - 1].flags.contains(Flags::WRAPLINE)
+ {
point.line -= 1;
}
diff --git a/alacritty_terminal/src/vi_mode.rs b/alacritty_terminal/src/vi_mode.rs
index 985d5455..20b132dd 100644
--- a/alacritty_terminal/src/vi_mode.rs
+++ b/alacritty_terminal/src/vi_mode.rs
@@ -381,7 +381,7 @@ fn is_space<T>(term: &Term<T>, point: Point<usize>) -> bool {
}
fn is_wrap<T>(term: &Term<T>, point: Point<usize>) -> bool {
- term.grid()[point.line][point.col].flags.contains(Flags::WRAPLINE)
+ point.line != 0 && term.grid()[point.line][point.col].flags.contains(Flags::WRAPLINE)
}
/// Check if point is at screen boundary.