Skip to content

Commit 00358bd

Browse files
committed
Ruby: Escape our completion options.
1 parent b9d4d6c commit 00358bd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

main.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
Readline.completer_quote_characters = "\"'"
1111

1212
Readline.completion_proc = proc do |input|
13-
CHARACTER_NAMES.select { |name| name.start_with?(input) }
13+
options = CHARACTER_NAMES
14+
if Readline.completion_quote_character.nil?
15+
options = options.map { |o| o.gsub(" ", "\\ ") }
16+
end
17+
18+
options.select { |name| name.start_with?(input) }
1419
end
1520

1621
puts "Who's your favourite Hitchiker's Guide character?"

0 commit comments

Comments
 (0)