textWidth ignores leading and trailing spaces #8067
Merged
perminder-17 merged 5 commits intoSep 5, 2025
Merged
Conversation
Collaborator
|
Hi, Thanks again for opening a PR on dev-2.0 branch. Actuallly, the reference looks something like this : Can you please replace your code with this sketch : https://editor.p5js.org/aman12345/sketches/E0wMMg6ha which shows how trailing spaces are ignored.? |
perminder-17
requested changes
Sep 4, 2025
Collaborator
perminder-17
left a comment
There was a problem hiding this comment.
Just some minor suggestion.
| test('should return a number for number input', function() { | ||
| assert.isNumber(myp5.textWidth(100)); | ||
| }); | ||
| test('should ignore leading and trailing spaces', function() { |
Collaborator
There was a problem hiding this comment.
Thanks for adding tests.
Co-authored-by: Perminder Singh <127239756+perminder-17@users.noreply.github.com>
Co-authored-by: Perminder Singh <127239756+perminder-17@users.noreply.github.com>
perminder-17
reviewed
Sep 5, 2025
Comment on lines
+820
to
+821
| * **Note:** In p5.js 2.0+, leading and trailing spaces are ignored. | ||
| * `textWidth(" Hello ")` returns the same width as `textWidth("Hello")`. |
Collaborator
There was a problem hiding this comment.
Just last suggestion, I think you cannot add a note between two example sketches. If you want to add this, you should move it to line number - 758.
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.

Resolves #8052
PR Checklist
npm run lintpasses