Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abbrev candidates feature #853

Merged
merged 1 commit into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/debug/abbrev_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ def type
nil
end
end

def candidates
@children.map{|c, n|
ss = n.candidates
ss.empty? ? c :
ss.map{|s|
c+s
}
}.flatten
end
end

# config: { type: [commands...], ... }
Expand Down Expand Up @@ -60,6 +70,7 @@ def search str, if_none = nil
return if_none
end
end
yield trie.candidates.map{|s| str + s} if block_given?
if_none
end
end
Expand Down
5 changes: 4 additions & 1 deletion lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,10 @@ def register_default_command
end

if sub
sub = info_subcommands_abbrev.search sub, :unknown
sub = info_subcommands_abbrev.search sub, :unknown do |candidates|
# note: unreached now
@ui.puts "Ambiguous command '#{sub}': #{candidates.join(' ')}"
end
end

case sub
Expand Down