In iTerm2 and Terminal.app on macOS, when the cursor is one past the end of line (i.e. the next character will be entered on the newline), the cursor position is regarded as being on that line rather than then next. When the backspace key is pressed, the logic that handles this case causes the rendering to move to the previous line and start rendering. This means that backspacing over newlines always breaks usages of dialoguer.
I'm not sure if this is a universal problem, a macOS specific issue, or one that is due to some personal random shell setting (I'm not aware of any that would affect this). Is this something others see?
VHS Tape file
```
Output backspace-eol.gif
Set FontSize 32
Set Width 800
Set Height 600
Type "echo Single backspace" Enter
Type "cargo run --quiet --example=input" Enter
Sleep 2s
Type "Test Backspace EOL1" Backspace
Sleep 1s
Type " Line2"
Sleep 2s
Ctrl+C Enter
Sleep 2s
Type "echo Double backspace" Enter
Type "cargo run --quiet --example=input" Enter
Sleep 2s
Type "Test Backspace EOL12" Backspace 2
Sleep 2s
Type " Line2" Enter
Ctrl+C Enter
Sleep 2s
Type "echo Triple backspace" Enter
Type "cargo run --quiet --example=input" Enter
Sleep 2s
Type "Test Backspace EOL123" Backspace 3
Sleep 2s
Type " Line2" Enter
Ctrl+C
Sleep 2s
```
In iTerm2 and Terminal.app on macOS, when the cursor is one past the end of line (i.e. the next character will be entered on the newline), the cursor position is regarded as being on that line rather than then next. When the backspace key is pressed, the logic that handles this case causes the rendering to move to the previous line and start rendering. This means that backspacing over newlines always breaks usages of dialoguer.
I'm not sure if this is a universal problem, a macOS specific issue, or one that is due to some personal random shell setting (I'm not aware of any that would affect this). Is this something others see?
iTerm2
https://github.com/console-rs/dialoguer/assets/381361/d30e58b8-2f6e-4ae9-8b6e-df6ce7d0e55b
Terminal.app
https://github.com/console-rs/dialoguer/assets/381361/278f8150-b493-4eeb-b71f-ee0a49e0ba45
The code in question is https://github.com/console-rs/dialoguer/blob/c5f7c9a59e775e23b74423155ae89342af12c049/src/prompts/input.rs#L333-L337
Repro using VHS:
VHS Tape file
``` Output backspace-eol.gif Set FontSize 32 Set Width 800 Set Height 600 Type "echo Single backspace" Enter Type "cargo run --quiet --example=input" Enter Sleep 2s Type "Test Backspace EOL1" Backspace Sleep 1s Type " Line2" Sleep 2s Ctrl+C Enter Sleep 2s Type "echo Double backspace" Enter Type "cargo run --quiet --example=input" Enter Sleep 2s Type "Test Backspace EOL12" Backspace 2 Sleep 2s Type " Line2" Enter Ctrl+C Enter Sleep 2s Type "echo Triple backspace" Enter Type "cargo run --quiet --example=input" Enter Sleep 2s Type "Test Backspace EOL123" Backspace 3 Sleep 2s Type " Line2" Enter Ctrl+C Sleep 2s ```