Describe the problem
Certain combinations of backspace and tabs cause the line input to get corrupted
Steps to reproduce the problem
Create the simple example below:
COMPLETIONS=%w'abc abc1 abc2'
reader = TTY::Reader.new(
completion_handler: ->(word) { COMPLETIONS.grep(/^#{Regexp.escape(word)}/) },
completion_suffix: " "
)
reader.on(:complete) do |event|
puts "#{event.line}\n#{event.completions.join("\n")}"
end
reader.read_line('>> ')
And press the following keys:
<TAB><TAB><BACKSPACE><BACKSPACE><TAB><TAB>
Actual behaviour
The following happens:
[key: <TAB>]
>> abc
abc
abc1
abc2
>> abc _
[key: <TAB>]
>> abc1
abc
abc1
abc2
>> abc1 _
[key: <BACKSPACE><BACKSPACE><TAB>]
>> abc
abc
abc1
abc2
>> abc _
[key: <TAB>]
>> aabc1
abc
abc1
abc2
>> aabc1 _
After the last <TAB>, the input line has prepended an extra 'a' character in front.
Expected behaviour
Line input after last <TAB> should be 'abc1 '
Describe your environment
- OS version: Linux Ubuntu 24.03
- Ruby version: 3.2.3
- TTY::Reader version: github head
Describe the problem
Certain combinations of backspace and tabs cause the line input to get corrupted
Steps to reproduce the problem
Create the simple example below:
And press the following keys:
Actual behaviour
The following happens:
After the last
<TAB>, the input line has prepended an extra'a'character in front.Expected behaviour
Line input after last
<TAB>should be'abc1 'Describe your environment