Bug
When lazygit exits, the cursor is moved back to the top of the terminal and the screen is not cleared. As a result, the shell prompt appears over the previous shell prompt at the top of the terminal. Previously, lazygit behaved like vim: it used the alternate screen and, on exit, returned me exactly to the shell screen state from before launching it with the cursor in the right position (last position). This bug does not happen in stock st or my highly patched new st build I'm working on.
To Reproduce
- Open
st.
- Spam enter to add lines of text.
- Run lazygit.
- Quit lazygit with
q.
- Observe the terminal after lazygit exits. Press enter to make it obvious.
Fix
Only handle non-private CSI u as cursor restore. Treat private CSI ? u as unknown, matching upstream st.
diff --git a/st.c b/st.c
index 7256475..ace700d 100644
--- a/st.c
+++ b/st.c
@@ -1880,7 +1880,11 @@ csihandle(void)
tcursor(CURSOR_SAVE);
break;
case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */
- tcursor(CURSOR_LOAD);
+ if (csiescseq.priv) {
+ goto unknown;
+ } else {
+ tcursor(CURSOR_LOAD);
+ }
break;
case ' ':
switch (csiescseq.mode[1]) {
Why
Newer terminal applications/libraries such as recent version of lazygit/tcell emit ESC[?u as a terminal capability/key protocol probe. CSI ? u is currently handled by the same branch as normal CSI u:
case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */
tcursor(CURSOR_LOAD);
break;
This means a private CSI query/probe is incorrectly treated as cursor restore. Stock current upstream st guards against private CSI u. Without it, ESC[?u incorrectly triggered tcursor(CURSOR_LOAD); witch caused the cursor to go to the top of the terminal upon exit.
Bug
When
lazygitexits, the cursor is moved back to the top of the terminal and the screen is not cleared. As a result, the shell prompt appears over the previous shell prompt at the top of the terminal. Previously,lazygitbehaved likevim: it used the alternate screen and, on exit, returned me exactly to the shell screen state from before launching it with the cursor in the right position (last position). This bug does not happen in stock st or my highly patched new st build I'm working on.To Reproduce
st.q.Fix
Only handle non-private
CSI uas cursor restore. Treat privateCSI ? uas unknown, matching upstreamst.Why
Newer terminal applications/libraries such as recent version of
lazygit/tcellemitESC[?uas a terminal capability/key protocol probe.CSI ? uis currently handled by the same branch as normalCSI u:This means a private CSI query/probe is incorrectly treated as cursor restore. Stock current upstream
stguards against private CSIu. Without it,ESC[?uincorrectly triggeredtcursor(CURSOR_LOAD);witch caused the cursor to go to the top of the terminal upon exit.