406 Commits

Author SHA1 Message Date
Lee Marlow
71d0481da8 Remove if check that was left in after change to exhaustive switch
This came out of cmd+triple-click fix in PR #5373
2025-01-29 11:38:35 -07:00
Daniel Patterson
4b8010a6f4 Change ifs to exhaustive switches 2025-01-26 15:22:23 +00:00
Daniel Patterson
645b4b0031 Fix cmd+triple click not selecting full output 2025-01-25 23:37:46 +00:00
Mitchell Hashimoto
cd2e2b801a Screen.cursorScrollAboveRotate memory corruption fix (#3129)
Extracted from #3110

Initial fix is relatively basic, and catching it with a test only
required a little bit of extra scrutiny of the cursor state after one of
the tests that we already had.

However, the fix revealed faulty dirty tracking logic throughout the
`cursorScrollAbove` function (and therefore bad results that were being
tested for when they should not have been). I've ended up clarifying
things, fixing the asserted dirty states in all the `cursorScrollAbove`
tests, and then finally implementing another very trivial fix that
catches the mistake.

Fixing the dirty tracking is really just an exercise in correctness
though, since when the scroll happens it inherently invalidates the
viewport, and therefore will trigger a full rebuild in the renderer...
unless, I guess, another operation is performed that cancels things out
and results in the viewport pin being in the same place as the previous
render, but that seems an exceptionally difficult scenario to make
happen on purpose much less accidentally.

This PR is almost entirely changes to comments and tests, there are only
2 lines of real code it changes, the one added to the start of
`cursorScrollAbove` and the one modified at the start of
`cursorScrollAboveRotate`. I believe these changes are entirely safe. (I
wonder if they might have a bad effect on our `vtebench` scrolling
performance though...)
2024-12-26 06:30:27 -08:00
Qwerasd
d030155c81 fix: unconditionally mark cursor row dirty in cursorScrollAbove
explained in comment
2024-12-25 21:15:58 -05:00
Qwerasd
67f51dcffd test: correct scroll above dirty assertions
Accounts for improved behavior due to prior memory corruption fix for
`cursorScrollAboveRotate` and reveals a new problem in a different
`cursorScrollAbove` sub-function.
2024-12-25 21:14:18 -05:00
Qwerasd
b68c161d98 improve comments
The new diagrams are different due to changes that have happened since
they were last generated.
2024-12-25 21:00:36 -05:00
Qwerasd
6d034d04a0 fix: memory corruption in Screen.cursorScrollAboveRotate
Unless it's guaranteed that the new pin is in the same page as the old
one, `cursor.page_pin` should only be updated through `cursorChangePin`,
not directly.
2024-12-25 20:09:20 -05:00
Qwerasd
a387e680ed test: add additional checks to scroll above cross-page test
Reveals a memory corruption issue caused by the direct assignment of
`cursor.page_pin` instead of using the `cursorChangePin` method.
2024-12-25 20:08:05 -05:00
Qwerasd
8f0dcb9d91 fix: memory corruption in Screen.cursorAbsolute
We call `cursorChangePin` which may invalidate the provided pin if it
needs to adjust the page capacity, and as such we should consider the
pin we pass in to it invalid afterwards, and access it through cursor
instead.
2024-12-25 19:04:35 -05:00
Qwerasd
b89e87c80d test: add failing test for Screen.cursorAbsolute memory corruption 2024-12-25 19:04:35 -05:00
Mitchell Hashimoto
53c41255eb terminal: selectionString only applies x offset on first/last page
Fixes #2841

We were incorrectly applying the start/end x offset for the first/last
row of every single page. If a selection spanned multiple pages this
would trim data incorrectly.

Unit test updated to cover this case.
2024-12-23 14:39:20 -08:00
Qwerasd
b44ebed798 Fix a scenario that could cause issues under some conditions
I don't know if this actually occurs in a way that can cause serious
problems, but it's better to nip it in the bud.
2024-12-23 15:45:30 -05:00
Jon Parise
82756f8b4c terminal: handle consecutive .input's in clearPrompt
Our semantic prompts are row-based, so the last prompt marker set on a
row "wins". In the case of at least our bash shell integration, this
means that consecutive prompt lines will all be marked as .input (OSC
133;B -- end-of-prompt, start of input).

Previously, clearPrompt() identified the current prompt's "area" by
searching upward from the current row until it encounters a .prompt
marker or some command output. In the bash case, .prompt is never the
dominant ("last") marker, so clearPrompt() would aggressively clear all
immediately preceding consecutive prompts.

With this change, we'll stop searching upwards when we encounter some
command output, a .prompt marker, _or another .input marker_. That last
case prevents clearPrompt() from unintentionally clearing earlier prompt
lines.

There may be improvements we can make to the way that our bash shell
integration emits semantic prompt markers, but I think this logic is
generally sound for all cases, and it specifically improves the current
bash prompt-clearing experience.
2024-12-16 21:06:15 -08:00
Mitchell Hashimoto
6f01dbf792 Select boundary dollar (#2938)
Proposed fix for #2933
2024-12-12 16:30:19 -08:00
Qwerasd
10abeba414 test: big perf win by pausing integ checks while growing pages
In multiple tests we create 1 or more pages by growing them 1 row at a
time, which results in an integrity check of the page for each row grown
which is just... horrible. By simply pausing integrity checks while
growing these pages (since growing them is not the point of the test) we
MASSIVELY speed up all of these tests.

Also reduced grapheme bytes during testing and made the Terminal "glitch
text" test actually assert what it intends to achieve, rather than just
blindly assuming 100 copies of the text will be the right amount -- this
lets us stop a lot earlier, making it take practically no time.
2024-12-12 16:58:48 -05:00
Toby Jaffey
47273de4c3 Added "selectWord with character boundary" test for dollar sign. 2024-12-12 16:47:04 +00:00
Toby Jaffey
5ef422b69a Add '$' to select boundaries, for same behaviour as iTerm 2024-12-11 23:38:34 +00:00
Mitchell Hashimoto
204e4f8663 terminal: support cell_map for encodeUtf8 2024-12-03 15:53:12 -08:00
Mitchell Hashimoto
bcefbfd7b4 terminal: move UTF8 encoding to Page and wrap around it 2024-12-03 15:53:12 -08:00
Mitchell Hashimoto
212bd3d5fb terminal: fullReset uses the new screen reset methods 2024-12-02 17:44:07 -05:00
Mitchell Hashimoto
aed51fd0b0 terminal: PageList rename "page" to "node" everywhere
This is more correct: a pagelist is a linked list of nodes, not pages.
The nodes themselves contain pages but we were previously calling the
nodes "pages" which was confusing, especially as I plan some future
changes to the way pages are stored.
2024-11-07 13:44:39 -08:00
Mitchell Hashimoto
6109edd00b terminal: refactor hyperlink memory management
Fixes #2500
Based on #2508

This separates out the concept of a "hyperlink" from a "hyperlink page
entry." The difference is that the former has real Zig slices into
things like strings and the latter has offsets into terminal page
memory.

From this separation, the Page structure now has an `insertHyperlink`
function that takes a hyperlink and converts it to a page entry.

This does a couple things: (1) it moves page memory management out of
Screen and into Page which is historically more appropriate and (2) it
let's us more easily test hyperlinks from the Page unit tests.

Finally, this PR makes some error sets explicit.
2024-10-28 15:30:04 -07:00
Marijn Besseling
4496e7d314 implement overline decoration (SGR 53/55) 2024-10-21 08:36:08 -04:00
Qwerasd
5138801b7b comment 2024-09-06 18:03:56 -04:00
Qwerasd
9669332134 terminal: cursorResetWrap should not reset wrap_continuation 2024-09-06 17:57:14 -04:00
Qwerasd
057f218c9e perf(terminal): specialize splitCellBoundary to cursor row
+ do some abstraction leakage in `cursorResetWrap`, since they're both
used in hot functions for TUI stuff so performance is important.
2024-09-06 13:26:57 -04:00
Qwerasd
8d12044f1d Terminal: fix ECH & DCH wide char boundary cond. behavior 2024-09-06 12:35:11 -04:00
Mitchell Hashimoto
6aab430caf terminal: disable slow safety tests in releasesafe 2024-08-31 21:14:12 -07:00
Mitchell Hashimoto
9d08ed32ee terminal: make error sets more explicit, capture explicit errors 2024-08-31 10:31:38 -07:00
Qwerasd
daa1755793 terminal/page: discriminate cloneFrom errors
Doing this makes it possible to appropriately handle a failed cloneFrom
operation by adjusting the correct part of the page capacity accordingly
2024-08-30 13:45:18 -04:00
Mitchell Hashimoto
6a2d57edfd terminal: cursorCopy has option to not copy hyperlink 2024-08-28 09:41:57 -07:00
Qwerasd
170f55aa84 Screen: update cursorCopy to handle hyperlink state 2024-08-27 01:07:29 -04:00
Qwerasd
cb1cb3526a test(Screen): add failing tests for cursorCopy hyperlink handling 2024-08-27 01:07:29 -04:00
Qwerasd
30bba9bf06 terminal: move refcount responsibility out of setHyperlink
avoids double counting in several places
2024-08-27 01:01:31 -04:00
Mitchell Hashimoto
9a287e1589 terminal: hyperlink state for cursor needs to be preserved on resize
When a screen is resized, the pages are generally reallocated. This
causes the cursor hyperlink state to be lost and ultimately the
hyperlink ref count is off by one.

The unit test in this commit showcases the issue very clearly. And you
can see we do this logic already for styles. We never copied it over for
hyperlinks.
2024-08-21 18:29:10 -04:00
Mitchell Hashimoto
37d19b3cef Merge pull request #2109 from edmz/block_hollow
Config: cursor-style can bet set to block_hollow
2024-08-18 15:08:08 -07:00
Mitchell Hashimoto
18a8d2b01d Minor changes, mainly commenting to clarify some behaviors 2024-08-18 15:05:31 -07:00
Mitchell Hashimoto
994514981f terminal: handle case grow allocates but cursor is multiple pages back 2024-08-18 10:20:23 -07:00
Mitchell Hashimoto
602fea52ec terminal: cursorScrollAbove handles case of no new page, prev page 2024-08-18 10:14:35 -07:00
Mitchell Hashimoto
9898489e25 terminal: add Screen.cursorScrollAbove and tests 2024-08-17 21:57:07 -07:00
Eduardo Dominguez
2e70ad20df Config: cursor-style can bet set to block_hollow
`cursor-style` can now also be set to `block_hollow`, no other changes
in behaviour are added.
2024-08-16 15:25:44 -06:00
Qwerasd
c37ee6c428 fix(terminal): proper style cleanup in cursorCopy
Old implementation sometimes resulted in an attempt to free the style
from a different page than it originates. This way is also generally
cleaner.
2024-08-15 19:08:12 -04:00
Qwerasd
16284dbb3f test(terminal/Screen): add failing unit test for cursorCopy
Detects issue with style reference counting when the cursor is moved
across pages during the copy.
2024-08-15 19:06:41 -04:00
Łukasz Niemier
f9be02a20f chore: clean up typos 2024-08-05 13:56:57 +02:00
Mitchell Hashimoto
09e367fe09 Merge pull request #2015 from ghostty-org/kitty-unicode
Kitty Graphics Unicode Placeholders
2024-07-31 09:56:12 -07:00
Mitchell Hashimoto
6d2e97a2f1 terminal: cursorChangePin needs to migrate hyperlink state
Fixes #2007
2024-07-28 14:17:38 -07:00
Mitchell Hashimoto
3549619a64 terminal: introduce row bit for kitty virtual placeholders 2024-07-25 21:32:45 -07:00
Jon Parise
9369a1a34b terminal: test clearPrompt with a continuation 2024-07-17 20:41:46 -04:00
Qwerasd
6f1a2d1e8e terminal/Screen: fix trailing blank cell handling for wrapped rows in dumpString 2024-07-08 22:26:36 -04:00