Skip to content

docs(changelog): correct the _hasExplicitCrossWidth claim in the #180 entry - #183

Merged
anilcancakir merged 1 commit into
masterfrom
docs/correct-the-cross-width-claim
Aug 21, 2026
Merged

docs(changelog): correct the _hasExplicitCrossWidth claim in the #180 entry#183
anilcancakir merged 1 commit into
masterfrom
docs/correct-the-cross-width-claim

Conversation

@anilcancakir

Copy link
Copy Markdown
Collaborator

What

One sentence in the [Unreleased] entry for #180. It said the trailing newline caused a "miss" at _hasExplicitCrossWidth whose cost was a redundant wrapper. There was no miss.

Why

That predicate matches with a prefix test, not equality:

if (token.startsWith('w-') ||
    token.startsWith('min-w-') ||
    token.startsWith('max-w-')) {

'w-24\n'.startsWith('w-') is true, so a token ending a line was always detected there. The newline only defeated the two sites that compare for equality, _selfWrapsInFlex (token == 'grow', and the ^flex-[0-9]+$ regex) and _hasShrinkZero (token == 'shrink-0'), which are the two failures #180 reproduced and pinned.

This is a correction of the reasoning and not only the wording. I had explained the test I wrote for that site passing on master as the consequence being unobservable, with the child's own w-24 winning inside the stretch wrapper. The real reason is simpler: the predicate already worked. The change at that site is tokenization consistency across all five scans and nothing more, and that is now what the entry says.

CodeRabbit raised this on #180. I read its finding as claiming the entry asserted a behavioural fix, which the entry did not, so the thread closed with the mechanism agreed between us and this sentence left standing. It is still wrong, and it would otherwise ship verbatim in the next release notes, which is why it is worth a PR of its own rather than a note in a future one.

Scope

CHANGELOG.md only, one sentence, inside the unreleased section. No source change, so nothing in lib/ moves and the #180 fix itself is untouched.

python3 tool/check-docs.py: 0 issues across 72 doc pages.

…entry

The entry said the trailing newline caused a "miss" at that site whose cost was
a redundant wrapper. There was no miss. `_hasExplicitCrossWidth` matches with
`startsWith('w-')` rather than equality, and `'w-24\n'.startsWith('w-')` is
true, so a newline never hid an explicit width from it.

That also corrects the reasoning, not just the wording. The test written for
that site passed before the fix because the predicate already worked, not
because the consequence was unobservable, which is what the entry implied and
what I had concluded.

CodeRabbit raised this on #180 and I read its finding as claiming the entry
asserted a behavioural fix, which it did not, so the thread closed with the
mechanism agreed and this sentence left standing. Correcting it before it ships
in the 1.4.1 release notes.
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@anilcancakir
anilcancakir merged commit a298472 into master Aug 21, 2026
10 checks passed
@anilcancakir
anilcancakir deleted the docs/correct-the-cross-width-claim branch August 21, 2026 22:18
@kodizm

kodizm Bot commented Aug 21, 2026

Copy link
Copy Markdown

Note

Kodizm (AI-generated). May contain mistakes; verify before acting.

The correction replaces one overreaching claim with another: _hasExplicitCrossWidth did miss, just not for the reason the old sentence gave.

Major

CHANGELOG.md:13 — "never missed at all" and "a trailing newline never hid an explicit width from it" are false in general (correctness of the claim). The pre-fix scan was className.split(' ') (git show 193ce62^:lib/src/widgets/w_div.dart, line 882), and a single-space split glues a newline onto the front of the next line's first token whenever that token is not preceded by a space. startsWith('w-') is anchored at index 0, so a leading \n or \t defeats it. The standalone chunk 'w-24\n' — the one the entry reasons about — only exists when the token is preceded by a space, i.e. the indented triple-quote style, which is why the repo's own test case matched.

Ported the pre-fix predicate verbatim and ran it:

True   indented triple-quote (repo style)   "\n                w-24 shrink-0\n                bg-white\n              "
False  un-indented triple-quote             "\nflex-1\nw-24\nbg-white\n"
False  tab-indented                         "\n\tflex-1\n\tw-24\n"
False  newline-joined, no spaces            "p-4\nw-24"

So the accurate statement is narrower than either version: the predicate tolerated a trailing newline, and still missed a w- / min-w- / max-w- token that a leading newline or tab glued to the previous line. The knock-on sentence, "That is also the real reason a test written for it passed before the fix, and the reason it ships without one," inherits the same overreach — an un-indented or tab-indented className is a reproducible pre-fix miss at that site, so "ships without one" is a choice rather than a consequence.

Minor

CHANGELOG.md:13 — the entry still opens "Three of them split on a single space and therefore never matched it", then says the third of those three never missed. Both halves are individually defensible under the narrowed reading above, but as written they contradict each other in the same paragraph (maintainability). Naming the leading-vs-trailing whitespace distinction once would settle it.

Tests

No test change, and none is needed for a prose edit. test/widgets/w_div/multiline_classname_test.dart covers the two sites the entry credits (_selfWrapsInFlex, _hasShrinkZero) and deliberately covers nothing at _hasExplicitCrossWidth; per the finding above, that site is testable pre-fix via a tab-indented or un-indented className.

The rest of the entry checks out: three pre-fix sites used split(' ') (lines 790, 882, 981) and two already used RegExp(r'\s+') (1006, 1049), matching "all five scans"; _selfWrapsInFlex compares with token == 'grow' plus ^flex-[0-9]+$ and _hasShrinkZero with token == 'shrink-0', both equality, as described. Scope is CHANGELOG.md only — nothing under lib/ moves, so post-change sync surfaces 1, 2, 3 and 5 are not triggered.

Checks I ran

  • git show 193ce62^:lib/src/widgets/w_div.dart — confirmed the pre-fix split(' ') at the three sites and the startsWith predicate body.
  • Python port of the pre-fix predicate over five className shapes — 4 of 5 multi-line forms return False (output above).
  • flutter test test/widgets/w_div/multiline_classname_test.dart test/widgets/w_div/flex_stretch_test.dart00:02 +22: All tests passed!
  • python3 tool/check-docs.pychecked 72 doc pages + 3 linking files against 171 demo routes: 0 issue(s), matching the description.
  • Did not run the full suite, dart analyze or ./tool/coverage.sh 90: no Dart file changed in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant