diff --git a/src/ansi.c b/src/ansi.c
index d88e153..8df79b2 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -1438,8 +1438,8 @@ int c, intermediate;
}
else
{
- LeaveAltScreen(curr);
RestoreCursor(&curr->w_alt.cursor);
+ LeaveAltScreen(curr);
if (a1 == 47 && !i)
curr->w_saved.on = 0;