🐞 Don't let no-op actions clobber the cached base frame (grow-from-zero)#1117
Open
bit-saver wants to merge 1 commit into
Open
🐞 Don't let no-op actions clobber the cached base frame (grow-from-zero)#1117bit-saver wants to merge 1 commit into
bit-saver wants to merge 1 commit into
Conversation
`recomputeTargetFrame` unconditionally cached the frame returned by `WindowFrameResolver.getFrame`, including the zero-size centered sentinel that no-frame actions (.noAction/.noSelection/.cycle/.minimize/.hide, and window-focus actions) return. In a preview-only chord (e.g. trigger + a "do nothing" action, then an arrow), `lastAppliedFrame` is still nil, so the subsequent grow/shrink/move reads that sentinel from `cachedTargetFrame.raw` as its base and resizes from a zero-size box at screen center instead of the window's real frame. Skip caching for no-op/no-frame actions, preserving the real base frame — matching pre-refactor (1.4.2) behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
During a preview-only chord that starts with a no-op action (e.g. trigger + a "do nothing" action bound to a key, then an arrow to grow), the green preview collapses to a tiny zero-size box in the screen center, and the subsequent grow/shrink resizes from that box instead of the window's real frame.
Root cause
ResizeContextis reused across a chord.recomputeTargetFrameunconditionally caches the frame returned byWindowFrameResolver.getFrame. For no-frame actions (.noAction/.noSelection/.cycle/.minimize/.hideand window-focus actions),getFramereturns a zero-size centered sentinel — which then overwritescachedTargetFrame.raw. When the user next presses grow/shrink/move,WindowFrameResolver.calculateTargetFramereadscontext.lastAppliedFrame ?? context.cachedTargetFrame.rawas its base. In a preview-only chordlastAppliedFrameis stillnil(it's only set on an actual apply), so it falls through to the pollutedcachedTargetFrame.raw= the zero box, and grows from zero.Pre-refactor (1.4.2) never cached the sentinel: its no-op early-return sat before the
lastTargetFramestore, so the grow base stayed the real window frame. The refactor intorecomputeTargetFramelost that invariant.Fix
Skip caching in
recomputeTargetFramefor no-op / no-frame / window-focus actions (mirroring the guard already inWindowFrameResolver.getFrame), preserving the previously-cached real frame. Incremental grow during preview still works because real actions keep updatingcachedTargetFrame.raw.Testing
Built (Release) and verified:
trigger + do-nothing + Upnow grows from the window's real frame; repeated grow/shrink still steps correctly; normal single actions unaffected.