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

Make doc display correctly on the right edge #274

Merged
Merged
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
14 changes: 8 additions & 6 deletions lib/irb/input-method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def auto_indent(&block)
if just_cursor_moving and completion_journey_data.nil?
return nil
end
cursor_pos_to_render, result, pointer, dialog = context.pop(4)
cursor_pos_to_render, result, pointer, autocomplete_dialog = context.pop(4)
return nil if result.nil? or pointer.nil? or pointer < 0
name = result[pointer]
name = IRB::InputCompletor.retrieve_completion_data(name, doc_namespace: true)
Expand Down Expand Up @@ -355,13 +355,15 @@ def auto_indent(&block)
end
end
return nil if doc.nil?
width = 40
formatter = RDoc::Markup::ToAnsi.new
formatter.width = 40
str = doc.accept(formatter)
formatter.width = width
contents = doc.accept(formatter).split("\n")

x = cursor_pos_to_render.x + 40
y = cursor_pos_to_render.y + pointer - dialog.scroll_top
DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: str.split("\n"), bg_color: '49')
x = cursor_pos_to_render.x + autocomplete_dialog.width
x = cursor_pos_to_render.x - width if x + width >= screen_width
y = cursor_pos_to_render.y + pointer - autocomplete_dialog.scroll_top
DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
}

# Reads the next line from this input method.
Expand Down