mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 14:34:39 +02:00
[ruby/irb] Avoid completing empty input
(https://github.com/ruby/irb/pull/832)
The candidate list for empty input is all methods + all variables +
all constants + all keywords. It's a long list that is not useful.
812dc2df7b
This commit is contained in:
parent
73fb9c35ef
commit
66e0d92de5
3 changed files with 18 additions and 3 deletions
|
@ -406,7 +406,13 @@ module IRB
|
||||||
else
|
else
|
||||||
select_message(receiver, message, candidates.sort)
|
select_message(receiver, message, candidates.sort)
|
||||||
end
|
end
|
||||||
|
when /^\s*$/
|
||||||
|
# empty input
|
||||||
|
if doc_namespace
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if doc_namespace
|
if doc_namespace
|
||||||
vars = (bind.local_variables | bind.eval_instance_variables).collect{|m| m.to_s}
|
vars = (bind.local_variables | bind.eval_instance_variables).collect{|m| m.to_s}
|
||||||
|
|
|
@ -204,6 +204,13 @@ module TestIRB
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_not_completing_empty_string
|
||||||
|
assert_equal([], completion_candidates("", binding))
|
||||||
|
assert_equal([], completion_candidates(" ", binding))
|
||||||
|
assert_equal([], completion_candidates("\t", binding))
|
||||||
|
assert_equal(nil, doc_namespace("", binding))
|
||||||
|
end
|
||||||
|
|
||||||
def test_complete_symbol
|
def test_complete_symbol
|
||||||
symbols = %w"UTF-16LE UTF-7".map do |enc|
|
symbols = %w"UTF-16LE UTF-7".map do |enc|
|
||||||
"K".force_encoding(enc).to_sym
|
"K".force_encoding(enc).to_sym
|
||||||
|
|
|
@ -232,7 +232,8 @@ class IRB::RenderingTest < Yamatanooroti::TestCase
|
||||||
puts 'start IRB'
|
puts 'start IRB'
|
||||||
LINES
|
LINES
|
||||||
start_terminal(4, 19, %W{ruby -I#{@pwd}/lib #{@pwd}/exe/irb}, startup_message: 'start IRB')
|
start_terminal(4, 19, %W{ruby -I#{@pwd}/lib #{@pwd}/exe/irb}, startup_message: 'start IRB')
|
||||||
write("IR\C-i")
|
write("IR")
|
||||||
|
write("\C-i")
|
||||||
close
|
close
|
||||||
|
|
||||||
# This is because on macOS we display different shortcut for displaying the full doc
|
# This is because on macOS we display different shortcut for displaying the full doc
|
||||||
|
@ -268,7 +269,8 @@ class IRB::RenderingTest < Yamatanooroti::TestCase
|
||||||
puts 'start IRB'
|
puts 'start IRB'
|
||||||
LINES
|
LINES
|
||||||
start_terminal(4, 12, %W{ruby -I#{@pwd}/lib #{@pwd}/exe/irb}, startup_message: 'start IRB')
|
start_terminal(4, 12, %W{ruby -I#{@pwd}/lib #{@pwd}/exe/irb}, startup_message: 'start IRB')
|
||||||
write("IR\C-i")
|
write("IR")
|
||||||
|
write("\C-i")
|
||||||
close
|
close
|
||||||
assert_screen(<<~EOC)
|
assert_screen(<<~EOC)
|
||||||
start IRB
|
start IRB
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue