mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 14:03:58 +00:00
Fix clipboard_paste nicer
Instead of hacking in arbitrary characters to avoid splitting, just
use `string collect`.
This reverts commit e450190d50
.
Fixes #7782, but nicer.
This commit is contained in:
parent
25d85bdc64
commit
10ef0d9daf
2 changed files with 3 additions and 9 deletions
|
@ -8,9 +8,7 @@ function __fish_tokenizer_state --description "Print the state of the tokenizer
|
|||
# - single-escaped - open \\ inside single-quotes
|
||||
# - double-escaped - open \\ inside double-quotes
|
||||
|
||||
# Don't expect one arg only, as (commandline -ct) may evaluate to multiple arguments since
|
||||
# output is forcibly split on new lines (issue #7782).
|
||||
argparse --min-args 1 i/initial-state= -- $argv
|
||||
argparse --min-args 1 --max-args 1 i/initial-state= -- $argv
|
||||
or return 1
|
||||
|
||||
set -l state normal
|
||||
|
@ -18,11 +16,7 @@ function __fish_tokenizer_state --description "Print the state of the tokenizer
|
|||
set str $_flag_initial_state
|
||||
end
|
||||
|
||||
# HACK: We care about quotes and don't care about new lines, joining multi-line arguments
|
||||
# produced by (commandline -ct) on anything other than \n will corrupt the contents but will
|
||||
# allow the following logic to work (including escape of subsequent character). This entire
|
||||
# function should probably be implemented as part of the `commandline` builtin.
|
||||
for char in (string split -- "" (string join -- \x1e $argv))
|
||||
for char in (string split -- "" $argv[1])
|
||||
switch $char
|
||||
case "'" # single-quote
|
||||
switch $state
|
||||
|
|
|
@ -26,7 +26,7 @@ function fish_clipboard_paste
|
|||
# in order to turn it into a single literal token.
|
||||
#
|
||||
# This eases pasting non-code (e.g. markdown or git commitishes).
|
||||
set -l quote_state (__fish_tokenizer_state -- (commandline -ct))
|
||||
set -l quote_state (__fish_tokenizer_state -- (commandline -ct | string collect))
|
||||
if contains -- $quote_state single single-escaped
|
||||
if status test-feature regex-easyesc
|
||||
set data (string replace -ra "(['\\\])" '\\\\$1' -- $data)
|
||||
|
|
Loading…
Reference in a new issue