fish integration: Remove newlines from the data in __ksi_transmit_data

Moving the operation of removing whitespace characters to the function
that transmits the data. This matches the implementation in zsh and bash
integration scripts.
This commit is contained in:
pagedown 2023-03-09 21:10:08 +08:00
parent 88443ef8a5
commit 6c182a00a8
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB

View File

@ -161,11 +161,12 @@ function edit-in-kitty --wraps "kitten edit-in-kitty" -d "Edit the specified fil
end end
function __ksi_transmit_data -d "Transmit data to kitty using chunked DCS escapes" function __ksi_transmit_data -d "Transmit data to kitty using chunked DCS escapes"
set --local data_len (string length -- "$argv[1]") set --local data (string replace --regex --all -- "\s" "" "$argv[1]")
set --local data_len (string length -- "$data")
set --local pos 1 set --local pos 1
set --local chunk_num 0 set --local chunk_num 0
while test "$pos" -le $data_len while test "$pos" -le $data_len
printf \eP@kitty-%s\|%s:%s\e\\ "$argv[2]" "$chunk_num" (string sub --start $pos --length 2048 -- $argv[1] | string collect) printf \eP@kitty-%s\|%s:%s\e\\ "$argv[2]" "$chunk_num" (string sub --start $pos --length 2048 -- "$data")
set pos (math $pos + 2048) set pos (math $pos + 2048)
set chunk_num (math $chunk_num + 1) set chunk_num (math $chunk_num + 1)
end end
@ -191,5 +192,5 @@ function clone-in-kitty -d "Clone the current fish session into a new kitty wind
set --local b64_envs (string join0 -- $envs | base64) set --local b64_envs (string join0 -- $envs | base64)
set --local b64_cwd (printf "%s" "$PWD" | base64) set --local b64_cwd (printf "%s" "$PWD" | base64)
set --prepend data "shell=fish" "pid=$fish_pid" "cwd=$b64_cwd" "env=$b64_envs" set --prepend data "shell=fish" "pid=$fish_pid" "cwd=$b64_cwd" "env=$b64_envs"
__ksi_transmit_data (string join "," -- $data | string replace --regex --all "\s" "") "clone" __ksi_transmit_data (string join "," -- $data) "clone"
end end