mirror of
https://github.com/ethauvin/sdkman-for-fish.git
synced 2025-04-25 21:27:11 -07:00
Account for fuzzy completions.
Introduced in Fish 3.1 cf. https://github.com/fish-shell/fish-shell/issues/5467 Needed to make tests less strict. Instead of checking the exact list of matches, we require the expected ones and exclude some others.
This commit is contained in:
parent
0c15f199cd
commit
479fa1e541
4 changed files with 154 additions and 115 deletions
21
test/features/support/parameter_types.rb
Normal file
21
test/features/support/parameter_types.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
ParameterType(
|
||||
name: 'patterns',
|
||||
regexp: %r{([^\s]*|'[^']*'|/[^/]*/)(,\s*([^\s]*|'[^']*'|/[^/]*/))*},
|
||||
type: Array,
|
||||
transformer: lambda do |*patterns|
|
||||
patterns \
|
||||
.map(&:strip) \
|
||||
.map do |s|
|
||||
s = if %r{^/(.*)/$} =~ s
|
||||
Regexp.last_match(1)
|
||||
elsif %r{^'(.*)'$} =~ s
|
||||
"^#{Regexp.escape(Regexp.last_match(1))}$"
|
||||
else
|
||||
"^#{Regexp.escape(s)}$"
|
||||
end
|
||||
Regexp.compile(s)
|
||||
end
|
||||
end
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue