mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 09:39:52 +08:00
Strip control characters from pasted text
We ignore typed control characters33a7172ee
(Revert to not inserting control characters from keyboard input, 2024-03-02). We used to do the same for bracketed paste but that changed in8bf8b10f6
(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 :)
This commit is contained in:
parent
a72ba0408f
commit
35b689335a
|
@ -1,6 +1,7 @@
|
||||||
function __fish_paste
|
function __fish_paste
|
||||||
# Also split on \r, otherwise it looks confusing
|
# Also split on \r, otherwise it looks confusing
|
||||||
set -l data (string split \r -- $argv[1] | string split \n)
|
set -l data (string split \r -- $argv[1] | string split \n)
|
||||||
|
set data (string replace -ra [[:cntrl:]] '' -- $data)
|
||||||
|
|
||||||
if commandline --search-field >/dev/null
|
if commandline --search-field >/dev/null
|
||||||
commandline --search-field -i -- $data
|
commandline --search-field -i -- $data
|
||||||
|
|
Loading…
Reference in New Issue
Block a user