From 8e58409930354c71c102ba7b86d1732b6c053642 Mon Sep 17 00:00:00 2001 From: jeremycostanzo <56163564+jeremycostanzo@users.noreply.github.com> Date: Sat, 18 Dec 2021 16:18:19 +0100 Subject: [PATCH] Remove trailing whitespace from block selection Fixes #5638. --- CHANGELOG.md | 1 + alacritty_terminal/src/term/mod.rs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a82835d3e4..74ab5fc5ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `ExpandSelection` is now a configurable mouse binding action - Config option `background_opacity`, you should use `window.opacity` instead - Reload configuration files when their symbolic link is replaced +- Strip trailing whitespaces when yanking from a block selection ### Fixed diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index 2908aadb85..820d8bd9c9 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -354,14 +354,16 @@ impl Term { if is_block { for line in (start.line.0..end.line.0).map(Line::from) { - res += &self.line_to_string(line, start.column..end.column, start.column.0 != 0); + res += self + .line_to_string(line, start.column..end.column, start.column.0 != 0) + .trim_end(); // If the last column is included, newline is appended automatically. if end.column != self.columns() - 1 { res += "\n"; } } - res += &self.line_to_string(end.line, start.column..end.column, true); + res += self.line_to_string(end.line, start.column..end.column, true).trim_end(); } else { res = self.bounds_to_string(start, end); }