[ruby/irb] Fixed sort of variables in completion

https://github.com/ruby/irb/commit/5842888255
This commit is contained in:
Imir Kiyamov 2022-07-18 19:45:38 +03:00 коммит произвёл git
Родитель 107acbd9a4
Коммит 83a6213f31
2 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -373,7 +373,7 @@ module IRB
if doc_namespace if doc_namespace
"String.#{candidates.find{ |i| i == message }}" "String.#{candidates.find{ |i| i == message }}"
else else
select_message(receiver, message, candidates) select_message(receiver, message, candidates.sort)
end end
else else
@ -390,7 +390,7 @@ module IRB
else else
candidates = (bind.eval_methods | bind.eval_private_methods | bind.local_variables | bind.eval_instance_variables | bind.eval_class_constants).collect{|m| m.to_s} candidates = (bind.eval_methods | bind.eval_private_methods | bind.local_variables | bind.eval_instance_variables | bind.eval_class_constants).collect{|m| m.to_s}
candidates |= ReservedWords candidates |= ReservedWords
candidates.grep(/^#{Regexp.quote(input)}/) candidates.grep(/^#{Regexp.quote(input)}/).sort
end end
end end
end end

Просмотреть файл

@ -208,5 +208,16 @@ module TestIRB
assert_include(IRB::InputCompletor.retrieve_completion_data("String.new", bind: binding), "String.new") assert_include(IRB::InputCompletor.retrieve_completion_data("String.new", bind: binding), "String.new")
assert_equal(IRB::InputCompletor.retrieve_completion_data("String.new", bind: binding, doc_namespace: true), "String.new") assert_equal(IRB::InputCompletor.retrieve_completion_data("String.new", bind: binding, doc_namespace: true), "String.new")
end end
def test_complete_sort_variables
xzy, xzy_1, xzy2 = '', '', ''
xzy.clear
xzy_1.clear
xzy2.clear
candidates = IRB::InputCompletor.retrieve_completion_data("xz", bind: binding, doc_namespace: false)
assert_equal(candidates, %w[xzy xzy2 xzy_1])
end
end end
end end