Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: completion test command sequence #4115

Merged
merged 4 commits into from
Dec 3, 2024

Conversation

LangLangBart
Copy link
Contributor

@LangLangBart LangLangBart commented Dec 2, 2024

description

Add a completion test for command sequences with different triggers.

Clean up global scope pollution in Zsh:

  • cmd_word doesn't need to be global since the zle __fzf_extract_command call doesn't actually
    create a new scope.
  • The completion widget is deleted after its usage; its sole purpose is to provide access to the words array.

Draft reason:

  • Unable to test semicolon (;) and backtick (`)
    • Using them in the test_go.rb file always ends in failure.
--- a/test/test_go.rb
+++ b/test/test_go.rb
@@ -3744,5 +3744,5 @@ module CompletionTest
     triggers = ['**', '~~', '++', 'ff', '/']
     # TODO: Find a way to test semicolon (';') and backtick ('`')
-    triggers.concat(['&', '[']) if instance_of?(TestZsh)
+    triggers.concat([';', '`', '&', '[']) if instance_of?(TestZsh)

     triggers.each do |trigger|

@junegunn
Copy link
Owner

junegunn commented Dec 3, 2024

Unable to test semicolon (;) and backtick (`)

tmux seems to treat a trailing semicolon differently (no official source, just an observation, could be a bug).

$ tmux send-keys 'ha;ha'; echo
ha;ha
$ tmux send-keys 'ha;ha;'; echo
ha;ha
$ tmux send-keys 'ha;ha\;'; echo
ha;ha;

Which means we would have to escape it to \; or ;;.

diff --git a/test/test_go.rb b/test/test_go.rb
index 98c2f25..11dc7a0 100755
--- a/test/test_go.rb
+++ b/test/test_go.rb
@@ -164,6 +164,7 @@ class Tmux
   private
 
   def go(args)
+    args = args.map { |a| a.sub(/;$/, '\;') }
     IO.popen(%w[tmux] + args) { |io| io.readlines(chomp: true) }
   end
 end

Not sure about backticks yet.

@LangLangBart LangLangBart marked this pull request as ready for review December 3, 2024 09:21
Copy link
Owner

@junegunn junegunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@junegunn junegunn merged commit a6957ab into junegunn:master Dec 3, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants