Ok this is ... a weird one, but i have code to reproduce it. The following code should produce this output:
cols: 136
1
12
123
1234
12345
123456
1234567
123456789
1234567890
12345678901
123456789012
1234567890123
123456789012345
The number after cols changes to display the number of columns being displayed in your terminal. For me it screws it up in a slightly different way at each width below 136 columns. Noting that the number of columns can be much wider than the width of the prompt text. For example a prompt with a max width of 15 columns is borked on an 80 column width window:
cols: 80
1
12
123
1234
12345
123456
1234567
123456789
1234567890
12345678901
3456789012 <----- borked line
1234567890123
12345678901234
123456789012345
crystal 0.23.1_3 and 0.24.2_1
mac os 10.13.4 (17E199)
happens in iTerm 2 and Terminal.app
save this as a crystal file and run with crystal run my_file.cr
the loop waits for your input so run, observe, resize window, hit enter, observe, resize window, hit enter, observe etc...
require "readline"
message = "1
12
123
1234
12345
123456
1234567
123456789
1234567890
12345678901
123456789012
1234567890123
12345678901234
123456789012345"
while (true)
cols = `tput cols`
input = Readline.readline("cols: #{cols}\n#{message}").to_s
end
Readline should be moved to a shard. I think nobody in the core team knows readline.
Not relevant any more, see https://github.com/crystal-lang/crystal/pull/8364
Most helpful comment
Readline should be moved to a shard. I think nobody in the core team knows readline.