balance-sizes: preserve total weight instead of resetting to a constant - #57
Merged
Merged
Conversation
`balance-sizes` set every child's weight to the constant 1, which throws away the container's total. Weights are only turned into real sizes by the layout pass, which runs once after a whole binding's command list — so a `resize` later in the same list operated on a total that no longer matched the monitor, and the windows jumped. Redistribute the container's existing total equally instead. Ports nikitabobko#2211 (upstream issue nikitabobko#1837) Tests rewritten against the fork's test API (`BalanceSizesCommand(args:)` + `.defaultEnv.copy(\.workspaceName,)` instead of upstream's `parseCommand`, which the fork doesn't have in tests). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WBcwRe3CktWZGGcHJHP4ds
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.
balance-sizesassigned the constant weight1to every child, discarding the container's total. Weights are only converted to real sizes by the layout pass, which runs once after a binding's whole command list — so aresizerunning later in the same list worked against a total that no longer matched the monitor, and windows visibly jumped.Now the container's existing total is redistributed equally, which is the same visual result for
balance-sizesalone and correct forbalance-sizesfollowed byresize.Ports nikitabobko#2211 (author: @MsfPablo) — upstream issue nikitabobko#1837.
Fork adaptation: upstream's tests use a
parseCommand("...")test helper that doesn't exist in this fork, so the three tests were rewritten in the fork's style — directBalanceSizesCommand(args: BalanceSizesCmdArgs(rawArgs: []))/ResizeCommand(args:)construction withtry await ... .run(.defaultEnv.copy(\.workspaceName, name), .emptyStdin). Coverage is identical.Tests:
BalanceSizesCommandTest— existing test updated (three windows of weight 1/2/3 now balance to 2 each, not 1), plus a nested-container case and abalance-sizes→resizeregression case for nikitabobko#1837. All 3 pass../build-debug.sh -Xswiftc -warnings-as-errors✅ ·./swift-test.sh✅Docs: none needed (no user-visible flag/config change;
balance-sizesbehaves the same standalone).