Display command description in doc dialog on tab completion#1180
Open
Display command description in doc dialog on tab completion#1180
Conversation
The open_doc paths in dialog content methods duplicated logic already in display_document. Now the dialog lambda calls display_document directly for Alt+d, and the content methods only handle inline dialog rendering.
tompng
reviewed
Mar 12, 2026
lib/irb/command/base.rb
Outdated
| if current == indent | ||
| current << word | ||
| elsif current.length + 1 + word.length <= width | ||
| current << ' ' << word |
Member
There was a problem hiding this comment.
Is the intention of using ' ', a single whitespace, is to squeeze spaces in the text?
-s Show the super method.
↓
-s Show the super method.
If it's not, how about something like this?
parts = line.strip.split(/(\s+)/)
parts.each do |part|
# wrap if exceeded
if current != indent && current.length + part.length > width
result << current
current = indent.dup
end
# don't add spaces just after indent
current << part unless current == indent && part.match?(/\A\s+\z/)
end
# needs result.map(&:rstrip)It will preserve spaces for this case:
Usage: ls [obj] [-g [query]]
-g [query] Filter the output with a query.
-a [aa] Foo bar
-b [bbb] Baz
↑ this alignment will be kept
One good part of this: We can flexibly change the regexp such as line.strip.split(/(\s+)|\b/)
Split on /(\s+)/ instead of /\s+/ so multi-space gaps in help text (e.g. option alignment) are preserved when wrapping lines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Proposed by @elct9620
Screen.Recording.2026-03-09.at.13.04.21.mov
show_doc_dialog_procinto smaller focused methods (rdoc_dialog_contents,easter_egg_dialog_contents,command_doc_dialog_contents,dialog_doc_position)DocumentTargetclass hierarchy (CommandDocument,MethodDocument) to replace stringly-typed doc namespace returns for commandsdisplay_document, eliminating duplication between dialog Alt+d paths and perfect-match displayCommand::Base.doc_dialog_contentso commands own their presentation