Skip to content

Commit 79bf499

Browse files
committed
abbrev candidates feature
1 parent 81a812e commit 79bf499

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/debug/abbrev_command.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ def type
3232
nil
3333
end
3434
end
35+
36+
def candidates
37+
@children.map{|c, n|
38+
ss = n.candidates
39+
ss.empty? ? c :
40+
ss.map{|s|
41+
c+s
42+
}
43+
}.flatten
44+
end
3545
end
3646

3747
# config: { type: [commands...], ... }
@@ -60,6 +70,7 @@ def search str, if_none = nil
6070
return if_none
6171
end
6272
end
73+
yield trie.candidates.map{|s| str + s} if block_given?
6374
if_none
6475
end
6576
end

lib/debug/session.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,10 @@ def register_default_command
786786
end
787787

788788
if sub
789-
sub = info_subcommands_abbrev.search sub, :unknown
789+
sub = info_subcommands_abbrev.search sub, :unknown do |candidates|
790+
# note: unreached now
791+
@ui.puts "Ambiguous command '#{sub}': #{candidates.join(' ')}"
792+
end
790793
end
791794

792795
case sub

0 commit comments

Comments
 (0)