diff --git a/CHANGELOG.md b/CHANGELOG.md index 21baf89b..7a731886 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,8 @@ (https://codeberg.org/dnkl/foot/issues/291). * Sixel “current geometry” query response not being bounded by the current window dimensions (fixes `lsix` output) +* Entering the alt screen did not update the normal screen’s “saved + cursor” position. ### Security diff --git a/csi.c b/csi.c index e833d2a7..af079df7 100644 --- a/csi.c +++ b/csi.c @@ -493,6 +493,18 @@ decset_decrst(struct terminal *term, unsigned param, bool enable) if (enable && term->grid != &term->alt) { selection_cancel(term); + /* + * A ‘cursor restore’ *after* returning from alt screen + * should restore the cursor from where it was when + * *entering* alt mode. + * + * I.e. entering alt mode “overwrites” the previous saved + * cursor position. + * + * Checked by vttest 11.8.7.3 + */ + term->grid->saved_cursor = term->grid->cursor; + term->grid = &term->alt; term_cursor_to(