From ca1a2d1f68b299f07e9953f8d739a4b7c12bc7a0 Mon Sep 17 00:00:00 2001 From: aycabta Date: Wed, 25 Aug 2021 17:21:05 +0900 Subject: [ruby/reline] Show autocomplete correctly when starts from prev line https://github.com/ruby/reline/commit/f31a76ff31 --- lib/reline.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/reline.rb') diff --git a/lib/reline.rb b/lib/reline.rb index 72621fe190..eafed48053 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -196,11 +196,15 @@ module Reline result = nil end end - x = cursor_pos.x - Reline::Unicode.calculate_width(target) + target_width = Reline::Unicode.calculate_width(target) + x = cursor_pos.x - target_width if x < 0 x = screen_width + x + y = -1 + else + y = 0 end - [Reline::CursorPos.new(x, nil), result] + [Reline::CursorPos.new(x, y), result] } inner_readline(prompt, add_hist, true, &confirm_multiline_termination) -- cgit v1.2.3