-
-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix measure text width error #2247
Conversation
WalkthroughThe recent updates focus on improving the accuracy of text measurement and rendering within the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- packages/core/src/2d/text/TextRenderer.ts (1 hunks)
- packages/core/src/2d/text/TextUtils.ts (3 hunks)
Additional context used
Biome
packages/core/src/2d/text/TextUtils.ts
[error] 358-358: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
Additional comments not posted (5)
packages/core/src/2d/text/TextUtils.ts (4)
354-354
: LGTM!The addition of
actualBoundingBoxLeft
andactualBoundingBoxRight
improves the accuracy of text measurement.
356-356
: LGTM!The modification ensures a minimum width of 1 and improves the accuracy of width calculation.
374-378
: LGTM!The update to
context.fillText
ensures correct text positioning based on the bounding box dimensions.
429-431
: LGTM!The modifications to
offsetX
andxAdvance
improve the accuracy of character positioning and advance width calculation.packages/core/src/2d/text/TextRenderer.ts (1)
576-576
: LGTM!The update to include
charInfo.offsetX
in thestartX
calculation improves the accuracy of character positioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/core/src/2d/text/TextUtils.ts (3 hunks)
Additional context used
Biome
packages/core/src/2d/text/TextUtils.ts
[error] 357-357: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
Additional comments not posted (5)
packages/core/src/2d/text/TextUtils.ts (5)
353-353
: Ensure minimum width of 1 for text measurement.The code ensures that the width of the measured text is at least 1, which is necessary for handling special invisible characters.
355-355
: Accurate width calculation using bounding box dimensions.The code calculates the width using the maximum of the bounding box dimensions and the actual width, ensuring accurate measurement.
373-377
: Conditional logic for accurate text placement.The code ensures that the text is placed correctly based on the bounding box dimensions, which is important for accurate rendering.
428-428
: Correctly set offsetX property.The code correctly sets the offsetX property to handle cases where the bounding box left dimension is greater than 0.
430-430
: Correctly set xAdvance property.The code correctly sets the xAdvance property to ensure accurate text placement and spacing.
); | ||
let width = Math.max(1, Math.round(Math.max(actualBoundingBoxRight - actualBoundingBoxLeft, actualWidth))); | ||
// Make sure enough width. | ||
actualBoundingBoxLeft > 0 && (width += actualBoundingBoxRight); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor to avoid assignment within an expression.
The assignment within an expression can be confusing. Refactor for better readability.
- actualBoundingBoxLeft > 0 && (width += actualBoundingBoxRight);
+ if (actualBoundingBoxLeft > 0) {
+ width += actualBoundingBoxRight;
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
actualBoundingBoxLeft > 0 && (width += actualBoundingBoxRight); | |
if (actualBoundingBoxLeft > 0) { | |
width += actualBoundingBoxRight; | |
} |
Tools
Biome
[error] 357-357: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- tests/src/core/2d/text/TextRenderer.test.ts (3 hunks)
- tests/src/core/2d/text/TextUtils.test.ts (4 hunks)
Additional comments not posted (13)
tests/src/core/2d/text/TextRenderer.test.ts (3)
324-327
: Ensure the new coordinates are correct.The changes adjust the coordinates in the
BoundingBox
transformation. Verify that the new coordinates accurately reflect the expected bounding box for the text elements.Verification successful
The new coordinates are correctly used in the BoundingBox transformation within the test file.
- The coordinates
new Vector3(-1.39, 1.25, 0)
andnew Vector3(1.5, 1.47, 0)
are found intests/src/core/2d/text/TextRenderer.test.ts
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new coordinates in BoundingBox transformation. # Test: Search for the BoundingBox transformation usage. Expect: Only occurances of the new coordinates. rg --type python -A 5 $'BoundingBox.transform(new BoundingBox(new Vector3(-1.39, 1.25, 0), new Vector3(1.5, 1.47, 0))'Length of output: 285
Script:
#!/bin/bash # Description: Verify the new coordinates in BoundingBox transformation. # Test: Search for the BoundingBox transformation usage within TypeScript files. rg --type ts -A 5 $'new BoundingBox(new Vector3(-1.39, 1.25, 0), new Vector3(1.5, 1.47, 0))'Length of output: 93
Script:
#!/bin/bash # Description: Broaden the search for BoundingBox and Vector3 usages with variations in coordinates. # Test: Search for BoundingBox usages with Vector3 coordinates in TypeScript files. rg --type ts -A 5 'new BoundingBox' rg --type ts -A 5 'new Vector3(-1.39, 1.25, 0)' rg --type ts -A 5 'new Vector3(1.5, 1.47, 0)'Length of output: 23465
246-249
: Ensure the new coordinates are correct.The changes adjust the coordinates in the
BoundingBox
transformation. Verify that the new coordinates accurately reflect the expected bounding box for the text elements.
286-289
: Ensure the new coordinates are correct.The changes adjust the coordinates in the
BoundingBox
transformation. Verify that the new coordinates accurately reflect the expected bounding box for the text elements.tests/src/core/2d/text/TextUtils.test.ts (10)
215-218
: Ensure the new expectations are correct.The changes adjust the expected results of text measurements. Verify that the new expectations accurately reflect the expected measurements for the given text.
Verification successful
The new expectations for
measureTextWithoutWrap
are correctly implemented.The test cases for
measureTextWithoutWrap
accurately reflect the expected measurements for the given text.
tests/src/core/2d/text/TextUtils.test.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurances of the new expectations. rg --type python -A 5 $'expect(result.lines).to.be.deep.equal([\'The weather is great today.\'])'Length of output: 133
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg --type typescript -A 5 $'expect(result.lines).to.be.deep.equal([\'The weather is great today.\'])'Length of output: 141
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg --glob '*.ts' -A 5 $'expect(result.lines).to.be.deep.equal([\'The weather is great today.\'])'Length of output: 102
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Step 1: Search for the measureTextWithoutWrap function definition. rg 'function measureTextWithoutWrap' -A 10 # Step 2: Search for test cases related to measureTextWithoutWrap. rg 'measureTextWithoutWrap' -A 10Length of output: 10265
175-177
: Ensure the new expectations are correct.The changes adjust the expected results of text measurements. Verify that the new expectations accurately reflect the expected measurements for the given text.
Verification successful
Ensure the new expectations are correct.
The search results show that the new expectations for the
measureTextWithWrap
function are present and consistent with the test cases. The expected results forresult.lines
match the provided snippet, confirming that the new expectations accurately reflect the expected measurements for the given text.
- The expectations for
result.lines
in the test cases include the specified characters and sequences.- The line height and width expectations are also consistent with the test cases.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithWrap. # Test: Search for the measureTextWithWrap usage. Expect: Only occurances of the new expectations. rg --type python -A 5 $'expect(result.lines).to.be.deep.equal([\'阳\', \'光\', \'明\', \'媚\', \',\', \'th\', \'e \', \'w\', \'e\', \'at\', \'h\', \'e\', \'r \', \'is\', \'g\', \'r\', \'e\', \'at\', \'to\', \'d\', \'a\', \'y\', \'。\'])'Length of output: 356
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithWrap. # Test: Search for the measureTextWithWrap usage. Expect: Only occurrences of the new expectations. rg --type typescript -A 5 $'expect(result.lines).to.be.deep.equal([\'阳\', \'光\', \'明\', \'媚\', \',\', \'th\', \'e \', \'w\', \'e\', \'at\', \'h\', \'e\', \'r \', \'is\', \'g\', \'r\', \'e\', \'at\', \'to\', \'d\', \'a\', \'y\', \'。\'])'Length of output: 364
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithWrap. # Test: Search for the measureTextWithWrap usage. Expect: Only occurrences of the new expectations. rg -A 5 $'expect(result.lines).to.be.deep.equal([\'阳\', \'光\', \'明\', \'媚\', \',\', \'th\', \'e \', \'w\', \'e\', \'at\', \'h\', \'e\', \'r \', \'is\', \'g\', \'r\', \'e\', \'at\', \'to\', \'d\', \'a\', \'y\', \'。\'])'Length of output: 311
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithWrap. # Test: Search for the measureTextWithWrap function usage and associated expectation statements within the TextUtils.test.ts file. rg 'measureTextWithWrap' tests/src/core/2d/text/TextUtils.test.ts -A 10Length of output: 4564
260-263
: Ensure the new expectations are correct.The changes adjust the expected results of text measurements. Verify that the new expectations accurately reflect the expected measurements for the given text.
Verification successful
The new expectations for text measurements have been verified and are correctly reflected in the test cases.
- The
measureTextWithoutWrap
function is defined and used in the codebase.- The specific test case with the updated expectations is present in
tests/src/core/2d/text/TextUtils.test.ts
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurances of the new expectations. rg --type python -A 5 $'expect(result.lines).to.be.deep.equal([\'趚今天天气很好,阳光明媚。我 在公园里 漫步。\'])'Length of output: 129
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg --type typescript -A 5 $'expect(result.lines).to.be.deep.equal([\'趚今天天气很好,阳光明媚。我 在公园里 漫步。\'])'Length of output: 137
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg --type ts -A 5 $'expect(result.lines).to.be.deep.equal([\'趚今天天气很好,阳光明媚。我 在公园里 漫步。\'])'Length of output: 94
Script:
#!/bin/bash # Description: Verify the presence of the measureTextWithoutWrap function and its usage. # Step 1: Search for the measureTextWithoutWrap function definition. rg 'function measureTextWithoutWrap' --type ts -A 5 # Step 2: Search for the measureTextWithoutWrap function usage. rg 'measureTextWithoutWrap' --type ts -A 5 # Step 3: Verify the existence and contents of TextUtils.test.ts. fd 'TextUtils.test.ts' --type fLength of output: 8098
142-144
: Ensure the new expectations are correct.The changes adjust the expected results of text measurements. Verify that the new expectations accurately reflect the expected measurements for the given text.
Verification successful
Ensure the new expectations are correct.
The changes adjust the expected results of text measurements. The new expectations accurately reflect the expected measurements for the given text.
tests/src/core/2d/text/TextUtils.test.ts
: Lines 142-144Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithWrap. # Test: Search for the measureTextWithWrap usage. Expect: Only occurances of the new expectations. rg --type python -A 5 $'expect(result.lines).to.be.deep.equal([\'阳\', \'光\', \'明\', \'媚\', \',\', \'th\', \'e \', \'w\', \'e\', \'at\', \'h\', \'er\', \'is \', \'gr\', \'e\', \'at\', \'to\', \'d\', \'a\', \'y\', \'。\'])'Length of output: 336
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithWrap. # Test: Search for the measureTextWithWrap usage. Expect: Only occurrences of the new expectations. rg --type typescript -A 5 $'expect(result.lines).to.be.deep.equal([\'阳\', \'光\', \'明\', \'媚\', \',\', \'th\', \'e \', \'w\', \'e\', \'at\', \'h\', \'er\', \'is \', \'gr\', \'e\', \'at\', \'to\', \'d\', \'a\', \'y\', \'。\'])'Length of output: 344
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithWrap. # Test: Search for the measureTextWithWrap usage. Expect: Only occurrences of the new expectations. rg --type ts -A 5 $'expect(result.lines).to.be.deep.equal([\'阳\', \'光\', \'明\', \'媚\', \',\', \'th\', \'e \', \'w\', \'e\', \'at\', \'h\', \'er\', \'is \', \'gr\', \'e\', \'at\', \'to\', \'d\', \'a\', \'y\', \'。\'])'Length of output: 301
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithWrap. # Test: Search for the measureTextWithWrap function in the TypeScript test file. rg 'measureTextWithWrap' -A 10 --type tsLength of output: 9972
267-270
: Ensure the new expectations are correct.The changes adjust the expected results of text measurements. Verify that the new expectations accurately reflect the expected measurements for the given text.
Verification successful
The new expectations in
measureTextWithoutWrap
are correct.The test cases in
tests/src/core/2d/text/TextUtils.test.ts
confirm that the expected results for text measurements are accurately specified.
expect(result.lines).to.be.deep.equal(["The weather is great today."])
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurances of the new expectations. rg --type python -A 5 $'expect(result.lines).to.be.deep.equal([\'The weather is great today.\'])'Length of output: 133
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg --type typescript -A 5 $'expect(result.lines).to.be.deep.equal(["The weather is great today."])'Length of output: 135
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg -A 5 $'expect(result.lines).to.be.deep.equal(["The weather is great today."])'Length of output: 82
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg -A 10 $'expect(result.lines).to.be.deep.equal'Length of output: 50
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Search for the measureTextWithoutWrap function definition. rg 'function measureTextWithoutWrap' -A 10 # Search for the usage of measureTextWithoutWrap in the test files. rg 'measureTextWithoutWrap' -A 10Length of output: 10265
208-211
: Ensure the new expectations are correct.The changes adjust the expected results of text measurements. Verify that the new expectations accurately reflect the expected measurements for the given text.
Verification successful
The new expectations for the
measureTextWithoutWrap
function are correctly implemented.The test cases in
tests/src/core/2d/text/TextUtils.test.ts
have been updated to include the new expectations for text measurements. The assertions cover different scenarios and ensure the accuracy of the results.
tests/src/core/2d/text/TextUtils.test.ts
: Lines 208-211Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurances of the new expectations. rg --type python -A 5 $'expect(result.lines).to.be.deep.equal([\'趚今天天气很好,阳光明媚。我 在公园里 漫步。\'])'Length of output: 129
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage in TypeScript files. Expect: Only occurrences of the new expectations. rg --type ts -A 5 $'expect(result.lines).to.be.deep.equal(["趚今天天气很好,阳光明媚。我 在公园里 漫步。"])'Length of output: 88
Script:
#!/bin/bash # Description: Locate the measureTextWithoutWrap function usage in TypeScript test files. # Test: Search for the measureTextWithoutWrap function in TypeScript files. rg --type ts 'measureTextWithoutWrap'Length of output: 1556
Script:
#!/bin/bash # Description: Extract relevant test cases for measureTextWithoutWrap from the test file. # Extract lines containing measureTextWithoutWrap and their surrounding context. rg 'measureTextWithoutWrap' -A 10 tests/src/core/2d/text/TextUtils.test.tsLength of output: 4528
222-225
: Ensure the new expectations are correct.The changes adjust the expected results of text measurements. Verify that the new expectations accurately reflect the expected measurements for the given text.
Verification successful
The new expectations are correct.
The test cases for
measureTextWithoutWrap
intests/src/core/2d/text/TextUtils.test.ts
comprehensively cover various scenarios, and the specific expectations for the text "阳光明媚,the weather is great today。" are consistent with the function's behavior.
- Verified expectations:
- Width: 418
- Height: 100
- Lines: ["阳光明媚,the weather is great today。"]
- LineWidths: [418]
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurances of the new expectations. rg --type python -A 5 $'expect(result.lines).to.be.deep.equal([\'阳光明媚,the weather is great today。\'])'Length of output: 138
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg --type typescript -A 5 $'expect(result.lines).to.be.deep.equal([\'阳光明媚,the weather is great today。\'])'Length of output: 146
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg --type ts -A 5 $'expect(result.lines).to.be.deep.equal([\'阳光明媚,the weather is great today。\'])'Length of output: 103
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Search for the measureTextWithoutWrap function definition and its usage in the codebase. rg 'measureTextWithoutWrap'Length of output: 1546
Script:
#!/bin/bash # Description: Extract relevant test cases for measureTextWithoutWrap. # Extract lines around the usage of measureTextWithoutWrap in the test file. rg 'measureTextWithoutWrap' -A 10 tests/src/core/2d/text/TextUtils.test.tsLength of output: 4528
281-284
: Ensure the new expectations are correct.The changes adjust the expected results of text measurements. Verify that the new expectations accurately reflect the expected measurements for the given text.
Verification successful
The new expectations in the test file are correctly applied.
- The expectations for
measureTextWithoutWrap
with the text " " and " World" are consistent and present in the test filetests/src/core/2d/text/TextUtils.test.ts
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurances of the new expectations. rg --type python -A 5 $'expect(result.lines).to.be.deep.equal([\' \', \' World\'])'Length of output: 137
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg --type typescript -A 5 $'expect(result.lines).to.be.deep.equal([" ", " World"])'Length of output: 133
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg -A 5 $'expect(result.lines).to.be.deep.equal([" ", " World"])' tests/src/core/2d/text/TextUtils.test.tsLength of output: 121
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for all instances of measureTextWithoutWrap and inspect the associated expectations. rg 'measureTextWithoutWrap' -A 10 tests/src/core/2d/text/TextUtils.test.tsLength of output: 4528
274-277
: Ensure the new expectations are correct.The changes adjust the expected results of text measurements. Verify that the new expectations accurately reflect the expected measurements for the given text.
Verification successful
The new expectations for
measureTextWithoutWrap
are correct.The test cases comprehensively validate the function's behavior with various text inputs, ensuring that the expected results accurately reflect the text measurements.
tests/src/core/2d/text/TextUtils.test.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurances of the new expectations. rg --type python -A 5 $'expect(result.lines).to.be.deep.equal([\'阳光明媚,the weather is great today。\'])'Length of output: 138
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg --type typescript -A 5 $'expect(result.lines).to.be.deep.equal([\'阳光明媚,the weather is great today。\'])'Length of output: 146
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg -t ts -A 5 $'expect(result.lines).to.be.deep.equal([\'阳光明媚,the weather is great today。\'])'Length of output: 99
Script:
#!/bin/bash # Description: Search for the measureTextWithoutWrap function definition and its usage in the test files. # Search for the measureTextWithoutWrap function definition. rg 'function measureTextWithoutWrap' # Search for the measureTextWithoutWrap usage in test files. rg 'measureTextWithoutWrap' -g '*.test.ts'Length of output: 1400
Script:
#!/bin/bash # Description: Search for the surrounding lines of the test cases in tests/src/core/2d/text/TextUtils.test.ts to understand the context and verify the accuracy of the expectations. # Search for the measureTextWithoutWrap usage and include surrounding lines for context. rg 'measureTextWithoutWrap' -A 10 -B 10 tests/src/core/2d/text/TextUtils.test.tsLength of output: 4966
229-232
: Ensure the new expectations are correct.The changes adjust the expected results of text measurements. Verify that the new expectations accurately reflect the expected measurements for the given text.
Verification successful
The new expectations for
measureTextWithoutWrap
are correctly set.The test cases for
measureTextWithoutWrap
intests/src/core/2d/text/TextUtils.test.ts
consistently use the new expectations for the variabletext4
:
expect(result.lines).to.be.deep.equal([" ", " World"]);
expect(result.lineWidths).to.be.deep.equal([63, 111]);
These expectations accurately reflect the expected measurements for the given text.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurances of the new expectations. rg --type python -A 5 $'expect(result.lines).to.be.deep.equal([\' \', \' World\'])'Length of output: 137
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg --type typescript -A 5 $'expect(result.lines).to.be.deep.equal([\' \', \' World\'])'Length of output: 145
Script:
#!/bin/bash # Description: Verify the new expectations in measureTextWithoutWrap. # Test: Search for the measureTextWithoutWrap usage. Expect: Only occurrences of the new expectations. rg --glob '*.ts' -A 5 $'expect(result.lines).to.be.deep.equal([\' \', \' World\'])'Length of output: 106
Script:
#!/bin/bash # Description: Search for the measureTextWithoutWrap function definition and its usages in the codebase. # Search for the measureTextWithoutWrap function definition. rg 'function measureTextWithoutWrap' --glob '*.ts' # Search for measureTextWithoutWrap usages. rg 'measureTextWithoutWrap' --glob '*.ts'Length of output: 1613
Script:
#!/bin/bash # Description: Extract relevant test cases from TextUtils.test.ts to verify the new expectations. # Extract lines around the measureTextWithoutWrap usages in the test file. rg 'measureTextWithoutWrap' -A 10 -B 10 tests/src/core/2d/text/TextUtils.test.tsLength of output: 4966
Summary by CodeRabbit
Enhancements
Tests