Skip to content

Commit

Permalink
Display autocomplete below original line if end point was wrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Aug 24, 2021
1 parent 064d54f commit 49f3392
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/reline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ def readmultiline(prompt = '', add_hist = false, &confirm_multiline_termination)
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)

Expand Down
4 changes: 4 additions & 0 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ def just_cursor_moving
@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
Expand Down

0 comments on commit 49f3392

Please sign in to comment.