Skip to content

Commit ee9b33c

Browse files
committed
Sort constant completion's candidates
1 parent 19a2fcb commit ee9b33c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/irb/completion.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace
255255
candidates = []
256256
end
257257

258-
select_message(receiver, message, candidates, "::")
258+
select_message(receiver, message, candidates.sort, "::")
259259
end
260260

261261
when /^(:[^:.]+)(\.|::)([^.]*)$/

test/irb/test_completion.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,14 @@ def test_complete_sort_variables
196196

197197
class TestConstantCompletion < TestCompletion
198198
class Foo
199+
B3 = 1
199200
B1 = 1
200-
B2 = 2
201+
B2 = 1
201202
end
202203

203204
def test_complete_constants
204205
assert_equal(["Foo"], IRB::InputCompletor.retrieve_completion_data("Fo", bind: binding))
205-
assert_equal(["Foo::B1", "Foo::B2"], IRB::InputCompletor.retrieve_completion_data("Foo::B", bind: binding))
206+
assert_equal(["Foo::B1", "Foo::B2", "Foo::B3"], IRB::InputCompletor.retrieve_completion_data("Foo::B", bind: binding))
206207
assert_equal(["Foo::B1.positive?"], IRB::InputCompletor.retrieve_completion_data("Foo::B1.pos", bind: binding))
207208

208209
assert_equal(["::Forwardable"], IRB::InputCompletor.retrieve_completion_data("::Fo", bind: binding))

0 commit comments

Comments
 (0)