GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Excessive whitespace trimming with comment formatting by EkriirkE · Pull Request #26455 · astral-sh/ruff Conversation
Contributor
When formatting comments to ensure a whitespace between the hash and content, tabular indentation(s) are stripped. This should not be the case - to fall in line with how Black handles it, it treats any leading tab as a non-space and injects a space between the hash and tab. Write code with beautiful tabs. Comment out a few lines of code that include indentation. Also make general normal comments, lazily without proper spaces. Inspect formatted output that previous reformats are intact, and no tabs in new format are removed. If understand the code correctly, it already right-trims the comment first thing. Then it checks for special cases where spaces should not be injected (including a space already there), Then a special NBSP replacement. Finally, a left-trim - which as far as I can tell only serves to trim tabs at this point as all other whitespace occurrences are handled/ignored. Compiled locally, binaries replaced. Code with the above comment scenarios were reformatted as expected (aligning with black). Closes #25019
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
MichaReiser
requested changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. I think we need to preview gate this change, because it can change existing formatted code. To do so, add a new function similar to ruff/crates/ruff_python_formatter/src/preview.rs Lines 24 to 32 in 895e965
then check the preview state. Doing this is a bit annoying here, because it requires threading through the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It should not modify anything already formatted because it will have stripped any non-space-whitespace (tabs) for a space previously and anything with a space does not get this far into the logic (491: they are unaffected by this change).
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, sorry, my mistake
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
MichaReiser
self-requested a review
MichaReiser
enabled auto-merge (squash)
MichaReiser
approved these changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Uh oh!
There was an error while loading. Please reload this page.
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Comment space normalization dedents commented out code when using tabsUh oh!
There was an error while loading. Please reload this page. 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. | |||||||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |