mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-18 17:56:09 +03:00

Fixes #5718 When a terminal is resized with text reflow (i.e. soft-wrapped text), the cursor is generally reflowed with it. For example, imagine a terminal window 5-columns wide and you type the following without pressing enter. The cursor is on the X. ``` OOOOO OOX ``` If you resize the window now to 8 or more columns, this happens, as expected: ``` OOOOOOOX ``` As expected, the cursor remains on the "X". This behaves like any other text input... Terminals also provide an escape sequence to [save the cursor (ESC 7 aka DECSC)](https://ghostty.org/docs/vt/esc/decsc). This includes, amongst other things, the cursor position. The cursor can be restored with [DECRC](https://ghostty.org/docs/vt/esc/decrc). The behavior of the position of the _saved cursor_ in the context of text reflow is unspecified and varies wildly between terminals Ghostty does this right now (as do many other terminals): ``` OOOOOOOO X ``` This commit changes the behavior so that we reflow the saved cursor.