Skip to content

When --preview-window is left, changing preview state (hide > show) leaves dummy string #4465

@fsc0

Description

@fsc0

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.64.0 (ead3029)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

#!/usr/bin/env bash
#
# fzf-dummy-string-test.sh
#
# 1. Execute this script then type 'c'
# 2. Check 'hide-preview' works
# 3. Erase query keyword 'c'
# 4. Check 'show-preview' works
# 5. Check number '4' shows up beside of POS 0.
# 6. Open text editor then change the variable TEST_TEXT to "TEST TEST TEST"
# 7. Do step 1~4 again
# 8. Check there's no dummy string
#
# * This issue is reproducible in terminal applications like st, kitty, alacritty.

TEST_TEXT="TEST TEST TEST 12345"
#TEST_TEXT="TEST TEST TEST"

fzf_preview(){
	echo "preview string"
}
export -f fzf_preview

fzf_toggle_preview(){
	if (( FZF_POS == 0 )) || [[ "$FZF_QUERY" == c ]]; then
		echo "hide-preview"
	else
		echo "show-preview"
	fi
}
export -f fzf_toggle_preview

echo "$TEST_TEXT" |\
	FZF_DEFAULT_OPTS= fzf \
		--preview 'fzf_preview' \
		--preview-window left,20,border-none \
		--bind 'focus:transform:fzf_toggle_preview'
Image

NOTE : Other options at the --preview-window (like 20 and border-none) also affects the result.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions