summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-10-08 10:21:55 +0900
committergit <svn-admin@ruby-lang.org>2021-10-08 10:33:47 +0900
commit374efa8e302c8cd19bf41e3f6f87582532cce79c (patch)
treec20f070af9617483a7bbed6a8cd74efc34f2e3e5
parent5c02df829665ea2063c674fba93d3025817718cf (diff)
[ruby/irb] Specify whether to show the doc dialog on the left or right side by using variable names
https://github.com/ruby/irb/commit/a23a88b8c9
-rw-r--r--lib/irb/input-method.rb36
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index f005ed7474..9fba4ed852 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -367,27 +367,31 @@ module IRB
return nil if doc.nil?
width = 40
- x = cursor_pos_to_render.x + autocomplete_dialog.width
- if x + width > screen_width
- old_width = screen_width - (x + 0)
- new_x = autocomplete_dialog.column - width
- new_x = 0 if new_x < 0
- new_width = width > autocomplete_dialog.column ? autocomplete_dialog.column : width
- if old_width.positive? and new_width.positive?
- if old_width >= new_width
- width = old_width
+ right_x = cursor_pos_to_render.x + autocomplete_dialog.width
+ if right_x + width > screen_width
+ right_width = screen_width - (right_x + 0)
+ left_x = autocomplete_dialog.column - width
+ left_x = 0 if left_x < 0
+ left_width = width > autocomplete_dialog.column ? autocomplete_dialog.column : width
+ if right_width.positive? and left_width.positive?
+ if right_width >= left_width
+ width = right_width
+ x = right_x
else
- width = new_width
- x = new_x
+ width = left_width
+ x = left_x
end
- elsif old_width.positive? and new_width.negative?
- width = old_width
- elsif old_width.negative? and new_width.positive?
- width = new_width
- x = new_x
+ elsif right_width.positive? and left_width.negative?
+ width = right_width
+ x = right_x
+ elsif right_width.negative? and left_width.positive?
+ width = left_width
+ x = left_x
else # Both are negative width.
return nil
end
+ else
+ x = right_x
end
formatter = RDoc::Markup::ToAnsi.new
formatter.width = width