Summary: | Ctrl+Shift+K (Clear Scrollback and Reset) causes TTY to report incorrect size | ||
---|---|---|---|
Product: | [Applications] konsole | Reporter: | Roman Perepelitsa <roman.perepelitsa> |
Component: | emulation | Assignee: | Konsole Developer <konsole-devel> |
Status: | REPORTED --- | ||
Severity: | normal | CC: | justin.zobel |
Priority: | NOR | ||
Version: | 19.12.3 | ||
Target Milestone: | --- | ||
Platform: | Ubuntu | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
Roman Perepelitsa
2020-10-12 08:52:58 UTC
For the record, I've bumped into this bug while debugging https://github.com/romkatv/powerlevel10k/issues/1051#issuecomment-706986771. This is intentional, i.e. the tty window size is slightly increased then reverted to the original size, to workaround an issue where if you use "clear scrollback and reset" the shell prompt isn't redrawn. See: https://commits.kde.org/konsole/d346a2ccad3950dad5ec137edce27e2930d536d6 to see the issue (with both bash and zsh): - with xterm, press and hold Ctrl then middle click and select "Reset and clear saved lines" from the menu - with gnome-terminal -> Terminal -> "Reset and clear" so yes, it is a hack (a brilliant one, if I may say so), and it's still needed AFAICS. Thanks for the context. This hack causes issues when the content of prompt depends on the terminal dimensions. Here's an example: PROMPT=$'${(pl.$((COLUMNS))..-.)}\n> ' zsh -f --promptsubst If you run this command in Konsole and press Ctrl+Shift+K, you'll see a duplicate line at the top. This problem would be avoided if Ctr+Shift+K cleared scrollback and sent `^L` to the shell. This solution would rely on the shell being able to redraw its prompt upon receiving `^L`, which is not guaranteed in general. On the other hand, it's also not guaranteed that the shell redraws its prompt upon receiving SIGWINCH. FWIW, Clear Scrollback and Reset can be implemented in Zsh in terminal-agnostic manner. function clear-screen-and-scrollback() { printf '\e[3J' >$TTY && zle clear-screen } zle -N clear-screen-and-scrollback # Ctrl+Alt+k -- Clear Scrollback and Reset. bindkey '^[^k' clear-screen-and-scrollback (In reply to Roman Perepelitsa from comment #3) > Thanks for the context. > > This hack causes issues when the content of prompt depends on the terminal > dimensions. Here's an example: > > PROMPT=$'${(pl.$((COLUMNS))..-.)}\n> ' zsh -f --promptsubst > > If you run this command in Konsole and press Ctrl+Shift+K, you'll see a > duplicate line at the top. > > This problem would be avoided if Ctr+Shift+K cleared scrollback and sent > `^L` to the shell. This solution would rely on the shell being able to > redraw its prompt upon receiving `^L`, which is not guaranteed in general. > On the other hand, it's also not guaranteed that the shell redraws its > prompt upon receiving SIGWINCH. > > FWIW, Clear Scrollback and Reset can be implemented in Zsh in > terminal-agnostic manner. > > function clear-screen-and-scrollback() { printf '\e[3J' >$TTY && zle > clear-screen } > zle -N clear-screen-and-scrollback > # Ctrl+Alt+k -- Clear Scrollback and Reset. > bindkey '^[^k' clear-screen-and-scrollback Roman would you be interested in supplying a patch to make the hack cleaner and work in all scenarios? Sorry, I'm already over-committed on other projects. Thanks for the update; changing status. Feel free to set the status to ASSIGNED once you have time to submit changes to our repositories. For more information, please see https://community.kde.org/Get_Involved/development#Submit_a_Merge_Request |