Merge branch 'pr-10682'

This commit is contained in:
Kovid Goyal 2026-10-18 07:57:46 +05:30
commit e9bd5a93f8
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 16 additions and 1 deletions

View file

@ -231,6 +231,8 @@ Detailed list of changes
0.50.0 [future]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fix cursor position reports returning the wrong row in origin mode
- macOS: A new option :opt:`restore_session_after_logout` to save the state of
every kitty instance, including the scrollback of every window, encrypted with
a key in the keychain, when logging out, restarting or shutting down the

View file

@ -3284,7 +3284,7 @@ report_device_status(Screen *self, unsigned int which, bool private) {
y++;
} else x--;
}
if (self->modes.mDECOM) y -= MAX(y, self->margin_top);
if (self->modes.mDECOM) y -= MIN(y, self->margin_top);
// 1-based indexing
int sz = snprintf(buf, sizeof(buf) - 1, "%s%u;%uR", (private ? "?" : ""), y + 1, x + 1);
if (sz > 0) write_escape_code_to_child(self, ESC_CSI, buf);

View file

@ -1013,6 +1013,19 @@ class TestParser(BaseTest):
self.ae(c.wtcbuf, b'\x1b[?2033;1$y')
pb('\033[?2033l', ('screen_reset_mode', 2033, 1))
def test_cursor_position_report_origin_mode(self) -> None:
s = self.create_screen(cols=10, lines=10)
for top in (1, 3):
for origin in (False, True):
parse_bytes(s, f'\033[{top};8r\033[?6{"h" if origin else "l"}'.encode())
for row in (1, 4):
parse_bytes(s, f'\033[{row};5H'.encode())
for private in ('', '?'):
with self.subTest(top=top, origin=origin, row=row, private=private):
s.callbacks.clear()
parse_bytes(s, f'\033[{private}6n'.encode())
self.ae(s.callbacks.wtcbuf, f'\033[{private}{row};5R'.encode())
def test_malformed_csi_subparam_does_not_corrupt_sgr(self):
# Regression for #10434: \e[?:m sets is_sub_param[0]=true in the CSI
# state. reset_csi must clear that flag so the next SGR isn't rejected.