Skip to content

Snap the Find window to its content while the results pane is hidden - #168

Merged
dayglojesus merged 1 commit into
mainfrom
fix/find-window-snap-height
Oct 27, 2026
Merged

dayglojesus merged 1 commit into
mainfrom
fix/find-window-snap-height

Conversation

@dayglojesus

Copy link
Copy Markdown
Collaborator

Summary

Pressing ⌘F in a document could open a very tall Find window with a large empty area between the options and the In: row.

The window autosaves its frame (frameAutosaveName "Find"). Close or quit while the results pane is showing and the saved frame is tall. In a new process with the pane hidden from the start, that frame is restored, the pane's own show/hide path in OakTransitionViewController (which resizes the window) never runs, and the layoutIfNeeded call in loadWindow does not shrink a window. The layout V:|[options]-[results]-[status]-[buttons]-| then has to put the slack somewhere, and the options grid, with the lowest vertical hugging priority, stretches. Reproduced in a fresh scratch process on a Mac whose saved frame was 785×998.

Change

  • SnapWindowToContent() sets the content height to the scaled container's intrinsic height (the content's fitting size × scale) when the window is created with the pane hidden, keeping the top edge in place.
  • windowWillResize:toSize: holds the height while the pane is hidden, so a drag cannot reopen the gap. Width still resizes. The pane's programmatic resizes do not pass through this delegate method and are unaffected.
  • New Frameworks/Find/tests/t_window_height.mm and textmate_add_tests(Find) in Frameworks/Find/CMakeLists.txt (the Find framework had no test target). The test restores a tall frame through the argument domain, loads the window with the Document target, and checks the content height equals the compact height and that a taller resize request is held. It failed with 966 != 252 before the change.

Verification

Debug build, fresh process, saved frame still 785×998 on disk:

Step Window height
⌘F in a document (pane hidden) 284
⇧⌘F Find in Project (pane shown) 998
⌘F back to Document 284

Before the change the first step gave 998 with the empty grid. Project results survive closing and reopening the window with ⇧⌘F, as before.

The CMakeLists.txt change is the test registration only, which is why the build chain guard needs the label.

Changelog

Find: The Find window no longer opens stretched with an empty area when the results pane is hidden.

The Find window autosaves its frame. A frame saved while the results
pane was showing is tall, and in a new process with the pane hidden
(searching the document) the window kept that height: the pane’s own
show and hide path, which resizes the window, never ran, and the
layoutIfNeeded call in loadWindow does not shrink a window. The options
grid, the only view without a firm height, stretched to fill the gap.

The window now snaps to the content’s fitting height when it is created
with the pane hidden, and windowWillResize:toSize: holds that height
while the pane is hidden so a drag cannot open the same gap. Width still
resizes, and the pane’s programmatic resizes are unaffected.

Adds the Find test target with a test that restores a tall frame and
checks the height; it failed with 966 != 252 before this change.
@dayglojesus dayglojesus added the build-chain-reviewed A maintainer reviewed the workflow, CMake, bin or entitlements changes in this pull request label Oct 27, 2026
@dayglojesus
dayglojesus merged commit 6a74f1c into main Oct 27, 2026
3 of 4 checks passed
@dayglojesus
dayglojesus deleted the fix/find-window-snap-height branch October 27, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-chain-reviewed A maintainer reviewed the workflow, CMake, bin or entitlements changes in this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant