mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/optparse.rb (OptionParser::Completion::complete): allow least
common completion for three or more candidates. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2d3a489f6d
commit
bc94ec8f4c
2 changed files with 16 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Nov 17 10:50:27 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/optparse.rb (OptionParser::Completion::complete): allow least
|
||||
common completion for three or more candidates.
|
||||
|
||||
Mon Nov 17 09:41:38 2003 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||
|
||||
* lib/test/unit/ui/tk/testrunner.rb,
|
||||
|
|
|
@ -83,6 +83,7 @@ Keyword completion module.
|
|||
pat ||= Regexp.new('\A' + Regexp.quote(key).gsub(/\w+(?=.)/, '\&\w*'),
|
||||
ignore_case?)
|
||||
canon, sw, k, v, cn = nil
|
||||
candidates = []
|
||||
each do |k, *v|
|
||||
(if Regexp === k
|
||||
kn = nil
|
||||
|
@ -92,14 +93,20 @@ Keyword completion module.
|
|||
pat === kn
|
||||
end) or next
|
||||
v << k if v.empty?
|
||||
if !canon
|
||||
canon, sw, cn = k, v, kn
|
||||
elsif sw != v
|
||||
candidates << [k, v, kn]
|
||||
end
|
||||
candidates = candidates.sort_by {|k, v, kn| kn.size}
|
||||
if candidates.size == 1
|
||||
canon, sw, * = candidates[0]
|
||||
elsif candidates.size > 1
|
||||
canon, sw, cn = candidates.shift
|
||||
candidates.each do |k, v, kn|
|
||||
next if sw == v
|
||||
if String === cn and String === kn
|
||||
if cn.rindex(kn, 0)
|
||||
canon, sw, cn = k, v, kn
|
||||
next
|
||||
elsif kn.rindex(canon, 0)
|
||||
elsif kn.rindex(cn, 0)
|
||||
next
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue