Skip to content

Commit

Permalink
Fixing completion to show choices when there are more than one.
Browse files Browse the repository at this point in the history
  • Loading branch information
JEG2 committed Nov 5, 2008
1 parent e365839 commit 9994c66
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions highline/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Below is a complete listing of changes for each revision of HighLine.

== 1.5.0

* Fixed a bug that would prevent Readline from showing all completions.
(reported by Yaohan Chen)
* Added the ability to pass a block to HighLine#agree().
(patch by Yaohan Chen)

Expand Down
2 changes: 1 addition & 1 deletion highline/examples/using_readline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
require "highline/import"

loop do
cmd = ask("Enter command: ", %w{save load reset quit}) do |q|
cmd = ask("Enter command: ", %w{save sample load reset quit}) do |q|
q.readline = true
end
say("Executing \"#{cmd}\"...")
Expand Down
5 changes: 3 additions & 2 deletions highline/lib/highline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,9 @@ def get_line( )
@output = old_output

# prep auto-completion
completions = @question.selection.abbrev
Readline.completion_proc = lambda { |string| completions[string] }
Readline.completion_proc = lambda do |string|
@question.selection.grep(/\A#{Regexp.escape(string)}/)
end

# work-around ugly readline() warnings
old_verbose = $VERBOSE
Expand Down

0 comments on commit 9994c66

Please sign in to comment.