Closed Johann-Goncalves-Pereira closed 2 years ago
Thank you for the report! Hmm, but actually this is somewhat an intended behavior of ble.sh. There is a related discussion on this behavior:
Quote from https://github.com/akinomyoga/ble.sh/issues/114#issuecomment-850737131 by @akinomyoga
Unless we clear all the terminal contents on resizing, it is difficult to handle it properly. It is related to the text reflow of the terminal where the terminal itself rearranges its contents on resizing. But the reflow algorithm depends on the terminal and also on the current cursor position (which
ble.sh
doesn't track), so it is almost impossible to know how the previous prompts and status lines are reflowed.
The original Bash tries to locate the prompt after the text reflowing based on guess, erases the old prompt, and redraws the new prompt on resizing. This causes a problem when the guess is wrong. The output of the previous command can be lost by erasing the old prompt based on the guess. For example, see the following behavior (Fig. 1) in the plain Bash (without ble.sh) where the output of the previous command "hello" is lost after resizing:
Fig. 1: The behavior of the plain Bash (readline).
https://user-images.githubusercontent.com/8982192/138536656-7ef86775-810b-4123-8352-e57f61a416f8.mp4
The behavior really depends on the text reflow algorithm of the terminal you use, so the behavior might not be reproduced in your terminal/terminal multiplexer. The above video was recorded with Terminator 1.92.
I decided to let ble.sh do not erase previous lines on resizing but start to draw the prompt from the cursor position after the resizing so that the output of the previous commands will be preserved for sure. In the following example (Fig. 2) of ble.sh, you can see that the output of the previous command is preserved in the same situation as Fig. 1.
Fig. 2: The behavior of ble.sh.
https://user-images.githubusercontent.com/8982192/138537189-02c54e9b-2126-49f2-b1bf-3526b8c2e74f.mp4
Maybe I can add an option that switches the behavior. What do you think?
I think is a great Idea because I really don't like this behavior
OK! I'll support it later!
I have the same issue, I'm using Konsole and VScode's integrated terminal. This is specially annoying in VScode where I have to resize the terminal many times.
@guptapriyanshu7 exactly, I use VS Code too and to prompt at same time one running application and other to make commands, and every time I need to resize and the lines breaks 3/5 times
@Johann-Goncalves-Pereira @guptapriyanshu7 Sorry for the delay. I have added a new option canvas_winch_action
to change the behavior on SIGWINCH
in commit 2243e91. You can put the following setting in your ~/.blerc
.
# blerc
bleopt canvas_winch_action=redraw-prev
The default behavior (canvas_winch_action=redraw-here
) was not so much changed from before, but I would like to improve the behavior in the future so that it reduces the chances of the prompt reposition as far as the outputs of the previous commands are ensured to be not lost.
It seems there are no further problems, so I close the issue. Thank you two again for the report and information!
Thank you very much for adding this option.
One thing that needs to be done is to add a description of this option to the blerc
template.
In the commit https://github.com/akinomyoga/ble.sh/commit/2243e9117d2e7adad11b69d5ca04f2b2376c70b6 there seems to be some confusion with a different option name in the edit of blerc
.
Ah, you are right! Thank you! I have fixed it b1be640.
From https://github.com/akinomyoga/ble.sh/issues/142#issuecomment-955181640 by @akinomyoga (2021-10-30)
but I would like to improve the behavior in the future so that it reduces the chances of the prompt reposition as far as the outputs of the previous commands are ensured to be not lost.
I implemented the improvements to the default setting redraw-here
in commit a125187. It still doesn't work as users might expect when the user uses the right prompts, but I think now it would work as expected in most cases as far as the right prompts are not used.
When I use resize the terminal my with ble installed the line break, and it is really annoying
https://user-images.githubusercontent.com/62612685/138453316-23ffc7a1-7a6a-49fb-bcab-92bc018e2496.mp4