From 35b689335ae392187eb2308cb9bf7220e52c9a51 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 14 May 2024 22:51:50 +0200 Subject: [PATCH] Strip control characters from pasted text We ignore typed control characters 33a7172ee (Revert to not inserting control characters from keyboard input, 2024-03-02). We used to do the same for bracketed paste but that changed in 8bf8b10f6 (Extended & human-friendly keys, 2024-03-30) which made bracketed paste behave like fish_clipboard_paste; it inserts the exact input (minus leading whitespace etc). At that time it wasn't clear to me which behavior was the right one (because of the inconsistency between terminal and bracketed paste). As reported in https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$PEEOAoyJY-644amIio0CWmq1TkpEDdSy2QnfJdK-dco trailing tabs in pasted text can be confusing. There seems to be not real need to insert raw control characters into the command line, so let's strip them when pasting. Now the only way to insert a raw control character into the command line is to recall it from command history. Not sure what the behavior should be for that case, we can revisit that later. If we get rid of raw control characters entirely, then we can also delete the new "control pictures" rendering :) --- share/functions/__fish_paste.fish | 1 + 1 file changed, 1 insertion(+) diff --git a/share/functions/__fish_paste.fish b/share/functions/__fish_paste.fish index d520f75b0..aca62434e 100644 --- a/share/functions/__fish_paste.fish +++ b/share/functions/__fish_paste.fish @@ -1,6 +1,7 @@ function __fish_paste # Also split on \r, otherwise it looks confusing set -l data (string split \r -- $argv[1] | string split \n) + set data (string replace -ra [[:cntrl:]] '' -- $data) if commandline --search-field >/dev/null commandline --search-field -i -- $data