Shell integration: Fix PS2 support

zsh only redraws the prompt from the last PS2 on a multiline prompt.
Take this into account.
This commit is contained in:
Kovid Goyal 2021-10-22 12:02:21 +05:30
parent 729cea88f3
commit 6d02ef59f8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -53,6 +53,7 @@
if [[ "$_ksi_prompt[mark]" == "y" ]]; then _ksi_osc "133;$1"; fi if [[ "$_ksi_prompt[mark]" == "y" ]]; then _ksi_osc "133;$1"; fi
} }
_ksi_prompt[start_mark]="%{$(_ksi_mark A)%}" _ksi_prompt[start_mark]="%{$(_ksi_mark A)%}"
_ksi_prompt[secondary_mark]="%{$(_ksi_mark 'A;k=s')%}"
function _ksi_set_title() { function _ksi_set_title() {
if [[ "$_ksi_prompt[title]" == "y" ]]; then _ksi_osc "2;$1"; fi if [[ "$_ksi_prompt[title]" == "y" ]]; then _ksi_osc "2;$1"; fi
@ -87,6 +88,9 @@
# not called when the prompt is redrawn after a window resize or when a background # not called when the prompt is redrawn after a window resize or when a background
# job finishes # job finishes
if [[ "$PS1" != *"$_ksi_prompt[start_mark]"* ]]; then PS1="$_ksi_prompt[start_mark]$PS1" fi if [[ "$PS1" != *"$_ksi_prompt[start_mark]"* ]]; then PS1="$_ksi_prompt[start_mark]$PS1" fi
# PS2 is used for prompt continuation. On resize with a continued prompt only the last
# prompt is redrawn so we need to mark it
if [[ "$PS2" != *"$_ksi_prompt[secondary_mark]"* ]]; then PS2="$_ksi_prompt[secondary_mark]$PS2" fi
fi fi
_ksi_prompt[state]="precmd" _ksi_prompt[state]="precmd"
} }
@ -121,6 +125,7 @@
_ksi_mark "C"; _ksi_mark "C";
# remove the prompt mark sequence while the command is executing as it could read/modify the value of PS1 # remove the prompt mark sequence while the command is executing as it could read/modify the value of PS1
PS1="${PS1//$_ksi_prompt[start_mark]/}" PS1="${PS1//$_ksi_prompt[start_mark]/}"
PS2="${PS2//$_ksi_prompt[secondary_mark]/}"
fi fi
# Set kitty window title to the currently executing command # Set kitty window title to the currently executing command
_ksi_set_title "$1" _ksi_set_title "$1"