From abee152255387a5e0ee0543f275b792265e0ef5e Mon Sep 17 00:00:00 2001 From: LangLangBart <92653266+LangLangBart@users.noreply.github.com> Date: Fri, 5 Jun 2026 05:12:49 +0200 Subject: [PATCH] test: ALT-C regression tests discussed in https://github.com/junegunn/fzf/issues/4816 --- test/test_shell_integration.rb | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/test_shell_integration.rb b/test/test_shell_integration.rb index fcb96388..008106c5 100644 --- a/test/test_shell_integration.rb +++ b/test/test_shell_integration.rb @@ -100,6 +100,47 @@ module TestShell tmux.until { |lines| assert_equal '/tmp', lines[-1] } end + def test_alt_c_symlink + base = '/tmp/fzf-test-alt-c-symlink' + FileUtils.rm_rf(base) + FileUtils.mkdir_p("#{base}/real/subdir") + FileUtils.ln_s("#{base}/real", "#{base}/link") + + tmux.prepare + tmux.send_keys "cd #{base}/link", :Enter + tmux.prepare + tmux.send_keys :Escape, :c + tmux.until { |lines| assert_operator lines.match_count, :>, 0 } + tmux.send_keys 'subdir' + tmux.until { |lines| assert_equal 1, lines.match_count } + tmux.send_keys :Enter + tmux.prepare + tmux.send_keys :pwd, :Enter + tmux.until { |lines| assert_equal "#{base}/link/subdir", lines[-1] } + ensure + FileUtils.rm_rf(base) + end + + def test_alt_c_absolute_cmd + base = '/tmp/fzf-test-alt-c-absolute' + FileUtils.rm_rf(base) + FileUtils.mkdir_p(base) + + set_var('FZF_ALT_C_COMMAND', "echo #{base}") + + tmux.prepare + tmux.send_keys 'cd /tmp', :Enter + tmux.prepare + tmux.send_keys :Escape, :c + tmux.until { |lines| assert_equal 1, lines.match_count } + tmux.send_keys :Enter + tmux.prepare + tmux.send_keys :pwd, :Enter + tmux.until { |lines| assert_equal base, lines[-1] } + ensure + FileUtils.rm_rf(base) + end + def test_ctrl_r tmux.prepare tmux.send_keys 'echo 1st', :Enter