[前][次][番号順一覧][スレッド一覧]

ruby-changes:67386

From: aycabta <ko1@a...>
Date: Tue, 31 Aug 2021 15:20:31 +0900 (JST)
Subject: [ruby-changes:67386] a8e6a850d5 (master): [ruby/irb] Make show doc dialog appears on the left at the right edge

https://git.ruby-lang.org/ruby.git/commit/?id=a8e6a850d5

From a8e6a850d571ea798ea52753f6b3252c33dd1270 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Tue, 31 Aug 2021 14:06:36 +0900
Subject: [ruby/irb] Make show doc dialog appears on the left at the right edge

https://github.com/ruby/irb/commit/6480eddd31
---
 lib/irb/input-method.rb | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index f7a4fba..fb7e1d6 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -355,13 +355,15 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/input-method.rb#L355
         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
+      x = cursor_pos_to_render.x + autocomplete_dialog.contents_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: str.split("\n"), bg_color: '49')
+      DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, bg_color: '49')
     }
 
     # Reads the next line from this input method.
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]