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

ruby-changes:67303

From: aycabta <ko1@a...>
Date: Sun, 29 Aug 2021 20:30:42 +0900 (JST)
Subject: [ruby-changes:67303] fb9fe4c43f (master): [ruby/reline] Display autocomplete below original line if end point was wrapped

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

From fb9fe4c43fe37fb9c78090114d373b1eaf195fc9 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Tue, 24 Aug 2021 16:15:04 +0900
Subject: [ruby/reline] Display autocomplete below original line if end point
 was wrapped

https://github.com/ruby/reline/commit/49f3392d59
---
 lib/reline.rb             | 6 +++++-
 lib/reline/line_editor.rb | 4 ++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/reline.rb b/lib/reline.rb
index fade2da..72621fe 100644
--- a/lib/reline.rb
+++ b/lib/reline.rb
@@ -196,7 +196,11 @@ module Reline https://github.com/ruby/ruby/blob/trunk/lib/reline.rb#L196
             result = nil
           end
         end
-        [Reline::CursorPos.new(cursor_pos.x - Reline::Unicode.calculate_width(target), nil), result]
+        x = cursor_pos.x - Reline::Unicode.calculate_width(target)
+        if x < 0
+          x = screen_width + x
+        end
+        [Reline::CursorPos.new(x, nil), result]
       }
       inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
 
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 4dd4e6d..ffd5b9c 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -510,6 +510,10 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L510
       @line_editor.instance_variable_get(:@just_cursor_moving)
     end
 
+    def screen_width
+      @line_editor.instance_variable_get(:@screen_size).last
+    end
+
     def call
       instance_exec(&@proc_to_exec)
     end
-- 
cgit v1.1


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

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