Skip to content

Display command description in doc dialog on tab completion#1180

Open
st0012 wants to merge 4 commits intomasterfrom
display-command-help
Open

Display command description in doc dialog on tab completion#1180
st0012 wants to merge 4 commits intomasterfrom
display-command-help

Conversation

@st0012
Copy link
Member

@st0012 st0012 commented Mar 9, 2026

Summary

Proposed by @elct9620

Screen.Recording.2026-03-09.at.13.04.21.mov
  • Refactor show_doc_dialog_proc into smaller focused methods (rdoc_dialog_contents, easter_egg_dialog_contents, command_doc_dialog_contents, dialog_doc_position)
  • Introduce DocumentTarget class hierarchy (CommandDocument, MethodDocument) to replace stringly-typed doc namespace returns for commands
  • Display command description and help message in the autocomplete doc dialog popup when a command is selected
  • Consolidate full-screen doc display into display_document, eliminating duplication between dialog Alt+d paths and perfect-match display
  • Move command dialog content rendering to Command::Base.doc_dialog_content so commands own their presentation

st0012 added 3 commits March 9, 2026 11:55
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.
@st0012 st0012 added the enhancement New feature or request label Mar 9, 2026
@st0012 st0012 marked this pull request as ready for review March 9, 2026 13:05
if current == indent
current << word
elsif current.length + 1 + word.length <= width
current << ' ' << word
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants