-
Notifications
You must be signed in to change notification settings - Fork 446
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
Prevent wrapping file locations containing white space #1120
base: master
Are you sure you want to change the base?
Conversation
Interesting, calling super() inside a list comprehension does not work on python 3.9.. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1120 +/- ##
==========================================
+ Coverage 91.27% 91.29% +0.02%
==========================================
Files 27 27
Lines 4619 4630 +11
==========================================
+ Hits 4216 4227 +11
Misses 403 403
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
chunks = [[c] if c.startswith(enclosed_filename_start) else super_._split(c) for c in chunks] | ||
chunks = [c for c in chain.from_iterable(chunks) if c] | ||
return chunks | ||
|
||
|
||
def wraptext(text: str, width: int = 70, initial_indent: str = '', subsequent_indent: str = '') -> list[str]: |
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.
The documentation of wraptext()
should be updated to reflect the new behaviour (it says "This version does not wrap lines on hyphens in words.")
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.
Also, a little perf thing – maybe for this PR, maybe for a subsequent one: wraptext()
is called repeatedly in pofile.py
– it would be more efficient to construct two different TextWrapper
s in advance and call wrap()
on them.
I think babel.util.wraptext()
should probably be deprecated then.
I can whip up a PR to do that... #1140
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.
The documentation of wraptext() should be updated to reflect the new behaviour (it says "This version does not wrap lines on hyphens in words.")
This version doesn't wrap lines on hyphens either, unless I misunderstood your comment? Did you mean that we should add a comment about filenames containing spaces?
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.
Yeah, I meant adding a comment about the new filenames-with-spaces behavior.
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.
Comment added!
Rebased and fixed the tests caused by missing |
Closes #1078
Depends on #1105 (To see only the changes in this PR, look at the last two commits)Since #1105 wraps file names containing white space in special unicode markers, we look out for them when
wrapping comments.
The fix overrides the
_split
method ofTextWrapper
where we manually generate the indivisible chunks, taking intoaccount enclosed file names.
I test the the wrapping behavior with gettext 0.22.5 (which includes the enclosing logic) to make sure it's consistent