When a terminal app asks me for input and I press tab, it adds 4 spaces (as expected).
This doesn't happen if I start the same app with bash: here backspace deletes all 4 spaces.
Note: this only seems to happen the first time an app expects user-input. The second time around it works as expected.
The text was updated successfully, but these errors were encountered:
I had to read the problem statement a couple of times before I understood the issue. The first thing to note is this has nothing to do with whether your terminal or app has tab stops every 4 or 8 spaces. The second thing is that the unexpected behavior occurs with other shells such as fish.
It helps to use a concrete example since phrases like "terminal app" could mean practically anything. The easiest way to reproduce the problem is to use
The first line is the point where you pressed [enter] after typing the
Now do the same experiment only starting with
Notice the absence of ANSI escape sequences. This means that after the
The solution is to output a carriage-return after the escape sequences to reset the terminal state. The carriage return will cause the tty driver to think the cursor is in column one but should otherwise have no other effect.