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:
Raphael Reitzig 2020-05-26 00:00:04 +02:00
parent 0c15f199cd
commit 479fa1e541
4 changed files with 154 additions and 115 deletions

View 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
)