From e83633f8dcfbf2ab8442d02e87afeeae4417a9dd Mon Sep 17 00:00:00 2001 From: jyn <github@jyn.dev> Date: Fri, 7 Mar 2025 09:46:36 -0500 Subject: [PATCH] Don't copy padding cells into the selection Tmux represents tab padding using '!' padding markers. Most commands check `GRID_FLAG_PADDING` and know not to render these. However, regex searching did not respect the padding flag. Steps to reproduce the issue this fixes: 1. `tmux set -g mode-flags vi` 2. `printf '\tfoo' 3. `C-b [ ?\sfoo<Enter>` (enter copy mode, search for "whitespace foo", copy the selection) 4. `C-b ]` (or any other method of pasting the current selection) That will show ' !!!!!!!foo' instead of ' foo'. --- window-copy.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window-copy.c b/window-copy.c index 7dcc8432..3a4f59bb 100644 --- a/window-copy.c +++ b/window-copy.c @@ -4263,6 +4263,8 @@ window_copy_match_at_cursor(struct window_copy_mode_data *data) buf = xrealloc(buf, len + 2); buf[len] = '\t'; len++; + } else if (gc.flags & GRID_FLAG_PADDING) { + /* nothing to do */ } else { buf = xrealloc(buf, len + gc.data.size + 1); memcpy(buf + len, gc.data.data, gc.data.size);