ruby / reline

The compatible library with the API of Ruby's stdlib 'readline'

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

newline not honored in Reline.readline("\nMy Prompt: ")

MadBomber opened this issue · comments

Description

When I start my prompt with "\n" I am expecting that character to start a new line not to be printed to the terminal as two characters "" and "n" in front of my prompt text

$ ruby temp.rb
\nMy Prompt: hello world
hello world

$ cat temp.rb
require 'reline'
answer = Reline.readline("\nMy Prompt: ")
puts answer

Ruby version 3.3.0

Terminal Emulator

iTerm2

I was bumping into the same issue. I worked around it like so:

*initial_prompt_lines, last_prompt_line = prompt_lines
puts initial_prompt_lines.join("\n") if initial_prompt_lines.any?
response = Reline.readline(last_prompt_line, history = false).chomp