Commit Graph

14105 Commits

Author SHA1 Message Date
Steven Lu
06130d40da split_tree: fix test passing wrong type to split()
The test was passing *TestView instead of *TestTree to the split()
function, which caused a compilation error.
2026-01-20 00:55:50 +07:00
Mitchell Hashimoto
f9699eceb0 terminal: PageList.compact 2026-01-19 09:18:58 -08:00
Mitchell Hashimoto
93436217c8 terminal: page.exactRowCapacity 2026-01-19 09:16:49 -08:00
Mitchell Hashimoto
d6cb84d12f terminal: remap tracked pins in backfill optimization path during resize (#10377)
Fixes #10369

When `resizeWithoutReflowGrowCols` copies rows to a previous page with
spare capacity, tracked pins pointing to those rows were not being
remapped. This left pins pointing to the original page which was
subsequently destroyed.

The fix adds pin remapping for rows copied to the previous page,
matching the existing remapping logic for rows copied to new pages.

I also added new integrity checks to verify that our tracked pins are
always valid at points where internal operations complete.

Thanks to @grishy for finding this!

**AI disclosure:** Amp used for verifying and fixing this bug. I
reviewed the results and just did minor manual tweaks.
https://ampcode.com/threads/T-019bd6d7-0645-73dd-8fd7-659f019fa83d and
https://ampcode.com/threads/T-019bd6c9-cc2e-73bc-bbaa-f8766e11c234
2026-01-19 09:15:09 -08:00
Mitchell Hashimoto
d67dd08a21 terminal: remap tracked pins in backfill path during resize
Fixes #10369

When `resizeWithoutReflowGrowCols` copies rows to a previous page with
spare capacity, tracked pins pointing to those rows were not being remapped. 
This left pins pointing to the original page which was subsequently destroyed.

The fix adds pin remapping for rows copied to the previous page,
matching the existing remapping logic for rows copied to new pages.

I also added new integrity checks to verify that our tracked pins are
always valid at points where internal operations complete.

Thanks to @grishy for finding this!
2026-01-19 09:11:49 -08:00
Jeffrey C. Ollie
9f16b8d112 osc 133: handle bare keys with no '=' (#10380)
Fixes #10379
2026-01-19 11:11:29 -06:00
Jeffrey C. Ollie
1daba40247 osc 133: handle bare keys with no '='
Fixes #10379
2026-01-19 10:59:00 -06:00
Steven Lu
6db4e437ca splits: make resize_split and toggle_split_zoom non-performable with single pane
When a tab contains only a single split, resize_split and toggle_split_zoom
actions now return false (not performed). This allows keybindings marked with
`performable: true` to pass the event through to the terminal program.

The performable flag causes unperformed actions to be treated as if the
binding didn't exist, so the key event is sent to the terminal instead of
being consumed.

- Add isSplit() helper to SplitTree to detect single-pane vs split state
- Update GTK resizeSplit/toggleSplitZoom to return false when single pane
- Update macOS resizeSplit/toggleSplitZoom to return Bool and check isSplit
- Add unit test for isSplit method
2026-01-19 17:34:34 +07:00
Tobias Kohlbau
836d794b9e termio: report color scheme synchronously
The reporting of color scheme was handled asynchronously by queuing a
handler in the surface. This could lead to race conditions where the
DSR is reported after subsequent VT sequences.

Fixes #5922
2026-01-19 07:49:57 +01:00
Mitchell Hashimoto
250877eff6 terminal: increaseCapacity should preserve dirty flag (#10374)
This never caused any known issues, but it's a bug! `increaseCapacity`
should produce a node with identical contents, just more capacity. We
were forgetting to copy over the dirty flag.

I looked back at `adjustCapacity` and it also didn't preserve the dirty
flag so presumably downstream consumers have been handling this case
manually. But, I think semantically it makes sense for
`increaseCapacity` to preserve the dirty flag.

This bug was found by AI (while I was doing another task). I fixed it
and wrote the test by hand though.
2026-01-18 14:52:56 -08:00
Mitchell Hashimoto
8d78a82d1b ssh-cache: use AtomicFile to write the cache file (#10365)
We previously wrote our new cache file into a temporary directory and
the (atomically) renamed it to the canonical cache file path. This
rename operation unfortunately only works when both files are on the
same file system, and that's not always the case (e.g. when $TMPDIR is
on its own file system).

Instead, we can use Zig's AtomicFile to safely perform this operation
inside of the cache directory.

There's a new risk of a crash leaving the temporary file around in this
directory (and not getting cleaned up like $TMPDIR-based files), but the
probability is low and those files will only be readable by the creating
user (mode 0o600).

There's a new test cash that verifies the expected AtomicFile clean up
behavior. I also switched the file-oriented tests to use testing.tmpDir
rather than using our application-level TempDir type.

Fixes #10364

---

**AI Disclosure:** I asked Claude to write the initial test case to
verify the AtomicFile cleanup behavior.
2026-01-18 14:52:30 -08:00
Mitchell Hashimoto
676b4993e8 Update iTerm2 colorschemes (#10363)
Upstream release:
https://github.com/mbadolato/iTerm2-Color-Schemes/releases/tag/release-20260112-150707-28c8f5b
2026-01-18 14:51:50 -08:00
Mitchell Hashimoto
3ee30058ab terminal: increaseCapacity should preserve dirty flag
This never caused any known issues, but it's a bug! `increaseCapacity`
should produce a node with identical contents, just more capacity. We
were forgetting to copy over the dirty flag.

I looked back at `adjustCapacity` and it also didn't preserve the dirty
flag so presumably downstream consumers have been handling this case
manually. But, I think semantically it makes sense for
`increaseCapacity` to preserve the dirty flag.

This bug was found by AI (while I was doing another task). I fixed it
and wrote the test by hand though.
2026-01-18 14:47:12 -08:00
Nishant Joshi
c8f56ddaf8 feat(macos): if the search box is empty directly close the box 2026-01-18 10:08:51 -08:00
shivaduke28
b0c868811d use underline instead of inverting colors for preedit text 2026-01-18 16:22:11 +09:00
Jon Parise
5423d64c6a ssh-cache: use AtomicFile to write the cache file
We previously wrote our new cache file into a temporary directory and
the (atomically) renamed it to the canonical cache file path. This
rename operation unfortunately only works when both files are on the
same file system, and that's not always the case (e.g. when $TMPDIR is
on its own file system).

Instead, we can use Zig's AtomicFile to safely perform this operation
inside of the cache directory.

There's a new risk of a crash leaving the temporary file around in this
directory (and not getting cleaned up like $TMPDIR-based files), but the
probability is low and those files will only be readable by the creating
user (mode 0o600).

There's a new test cash that verifies the expected AtomicFile clean up
behavior. I also switched the file-oriented tests to use testing.tmpDir
rather than using our application-level TempDir type.
2026-01-17 20:44:22 -05:00
mitchellh
73a8d64b8a deps: Update iTerm2 color schemes 2026-01-18 00:16:59 +00:00
Mitchell Hashimoto
9fb03ba55c terminal: grow prune check should not prune if required for active (#10353)
Fixes #10352

The bug was that non-standard pages would mix the old
`growRequiredForActive` check and make our active area insufficient in
the PageList.

But, since scrollbars now require we have a cached `total_rows` that our
safety checks always verify, we can remove the old linked list traversal
and switch to some simple math in general across all page sizes.
2026-01-16 21:34:16 -08:00
Mitchell Hashimoto
464c31328e terminal: grow prune check should not prune if required for active
Fixes #10352

The bug was that non-standard pages would mix the old
`growRequiredForActive` check and make our active area insufficient in
the PageList.

But, since scrollbars now require we have a cached `total_rows` that our
safety checks always verify, we can remove the old linked list traversal
and switch to some simple math in general across all page sizes.
2026-01-16 21:26:54 -08:00
Mitchell Hashimoto
56237efeef PageList overflow detection and protection (#10337)
Fixes #10258  
Replaces #10284

1. `Page.Capacity` now uses smaller bit-width integers that represent a
true maximum capacity for various fields.
2. On 64-bit systems, a maxed out `Page.Capacity` (every field `maxInt`)
can be represented in an addressable allocation (total required memory
less than 64 bits). This means `Page.layout` can't overflow.
3. All `adjustCapacity` functions replaced with `increaseCapacity` which
doesn't allow specifying the resulting value, which makes it so overflow
is only possible in significantly fewer places, making it easier to
handle in general.
4. `increaseCapacity` can return a new error `OutOfSpace` which happens
when overflow is detected. This means that no valid page can accommodate
the desired capacity increase because we're already at the max. The
caller is expected to handle this.
5. Updated our resize so that the only possible error is system OOM, we
handle the new `OutOfSpace` by copying the recent reflowed row into a
new page and continuing.

A very, very high-level overview is below. The "overflow" here papers
over a bunch of details where the prior usize capacities flowed through
to Page.layout and ultimately RefCountedSet and other managed types
which then caused incorrect calculations on total memory size required.

```mermaid
flowchart TB
    subgraph Before["Before: adjustCapacity"]
        A1[capacity: usize] --> A2["capacity *= 2"]
        A2 --> A3{Overflow?}
        A3 -->|"Not detected"| A4["Massive allocation or crash"]
    end
    
    subgraph After["After: increaseCapacity"]
        B1["capacity: bounded int<br/>(u16/u32)"] --> B2["capacity *= 2"]
        B2 --> B3{Overflow?}
        B3 -->|"OutOfSpace error"| B4["Graceful handling:<br/>move row to new page"]
        B3 -->|"Success"| B5["Normal allocation"]
    end
    
    Before --> After
    
    classDef beforeStyle fill:#3d1a1a,stroke:#ff6b6b,color:#ff6b6b
    classDef afterStyle fill:#1a3d3a,stroke:#4ecdc4,color:#4ecdc4
    
    class A1,A2,A3,A4 beforeStyle
    class B1,B2,B3,B4,B5 afterStyle
```
2026-01-16 14:52:28 -08:00
Mitchell Hashimoto
df35363b15 terminal: more robust handling of max_page_size
not 100%
2026-01-16 14:47:53 -08:00
Mitchell Hashimoto
442a395850 terminal: ensure our std_capacity fits within max page size 2026-01-16 14:25:01 -08:00
Mitchell Hashimoto
4770aba089 Misc bug fixes (#10349)
Just fixes for a couple bugs I happened across
2026-01-16 14:13:59 -08:00
Qwerasd
69066200ef fix: handle double tmux control mode exit command 2026-01-16 16:58:58 -05:00
Mitchell Hashimoto
85a3d623b2 terminal: increaseCapacity should reach maxInt before overflow 2026-01-16 13:43:56 -08:00
Qwerasd
4e5c1dcdc1 osc: fix bad indexing for empty kv in semantic prompt 2026-01-16 16:36:37 -05:00
Qwerasd
f89b6433c2 osc: add failing test for osc 133 parsing trailing ;
This actually causes a crash lol, bad indexing of a slice with `1..0`
because it's `key.len + 1 ..` and the length is `0`.
2026-01-16 16:29:59 -05:00
Mitchell Hashimoto
ec0a150098 terminal: moveLastRowToNewPage needs to fix up total_rows 2026-01-16 13:23:55 -08:00
Mitchell Hashimoto
c9d15949d8 terminal: on reflow OutOfSpace, move last row to new page and try again 2026-01-16 13:23:55 -08:00
Mitchell Hashimoto
42321cc7d5 terminal: write to the proper cell 2026-01-16 13:23:55 -08:00
Mitchell Hashimoto
97621ece93 terminal: handle reflowRow OutOfSpace by no-op 2026-01-16 13:23:55 -08:00
Mitchell Hashimoto
25643ec806 terminal: reflowRow extract writeCell 2026-01-16 13:23:55 -08:00
Mitchell Hashimoto
d626984418 terminal: reflowCursor improve error handling on assumed cases 2026-01-16 13:23:55 -08:00
Mitchell Hashimoto
6b2455828e terminal: resizeWithoutReflowGrowCols can only fail for OOM 2026-01-16 13:23:55 -08:00
Mitchell Hashimoto
e704525887 terminal: PageList remove adjustCapacity 2026-01-16 13:23:55 -08:00
Mitchell Hashimoto
b59ac60a87 terminal: remove Screen.adjustCapacity 2026-01-16 13:23:55 -08:00
Mitchell Hashimoto
c8afc42308 terminal: switch to increaseCapacity 2026-01-16 13:09:19 -08:00
Mitchell Hashimoto
25b7cc9f2c terminal: hyperlink state uses increaseCapacity on screen 2026-01-16 13:09:19 -08:00
Mitchell Hashimoto
29d4aba033 terminal: Screen replace adjust with increaseCapacity 2026-01-16 13:09:19 -08:00
Mitchell Hashimoto
1e5973386b terminal: Screen.increaseCapacity 2026-01-16 13:09:19 -08:00
Mitchell Hashimoto
8306f96d94 terminal: PageList.increaseCapacity 2026-01-16 13:07:32 -08:00
Mitchell Hashimoto
95a23f756d terminal: more strict sizing for page capacities, max cap can fit 64-bit 2026-01-16 13:07:32 -08:00
Mitchell Hashimoto
c8295815cb terminal: fix stale cursor pin usage after cursorChangePin (#10348)
Fixes #10282

The function `cursorChangePin` is supposed to be called anytime the
cursor page pin changes, but it itself may alter the page pin if setting
up the underlying managed memory forces a page size adjustment.

Multiple callers to this function were erroneously reusing the old page
pin value.

**AI disclosure:** I had Amp help me write the test. I eyeballed and
found the bug myself, verified it by asking Amp to write the test,
reviewed that manually, then implemented the fixes manually and got it
to pass.
2026-01-16 13:03:09 -08:00
Mitchell Hashimoto
f1dbdc7965 terminal: fix stale cursor pin usage after cursorChangePin
Fixes #10282

The function `cursorChangePin` is supposed to be called anytime the
cursor page pin changes, but it itself may alter the page pin if setting
up the underlying managed memory forces a page size adjustment. 

Multiple callers to this function were erroneously reusing the old page
pin value.
2026-01-16 12:57:29 -08:00
Jon Parise
204170d052 shellcheck: move common directives to .shellcheckrc (#10343)
This simplifies our CI command line and makes it easier to document
expected usage (in HACKING.md).

There unfortunately isn't a way to set --checked-sourced or our default
warning level in .shellcheckrc, and our `find` command is still a bit
unwieldy, but this is still a net improvement.
2026-01-16 10:41:01 -05:00
Jacob Sandlund
c587d7a3a0 fix Bengali, Tai Tham letters, and Devanagari tests 2026-01-16 10:29:49 -05:00
evertonstz
1c2c2257d4 Set default value for gtk_enable_primary_paste to true and simplify condition checks 2026-01-16 12:29:31 -03:00
Everton Correia
60da5eb3a6 Apply suggestion from @pluiedev
Co-authored-by: Leah Amelia Chen <github@acc.pluie.me>
2026-01-16 12:25:49 -03:00
Jacob Sandlund
6bcf030868 Merge remote-tracking branch 'upstream/main' into harfbuzz-positions 2026-01-16 09:40:16 -05:00
Jacob Sandlund
80bf50be1d set cluster level to match CoreText logic 2026-01-16 09:39:47 -05:00