Skip to content
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

Extract string part and normalized string #7219

Merged
merged 1 commit into from
Sep 8, 2023
Merged

Conversation

MichaReiser
Copy link
Member

Summary

This is a small refactor that extracts a NormalizedString data structure rather than just doing normalization during formatting.

Having a dedicated data structure that caches the normalized strings is important for implementing Black's preview style string formatting where it is necessary
to format the normalized string multiple times:

  1. Join all parts together
  2. Using the same separation as in the source
  3. Try to fit as many words as possible

Test Plan

cargo test

@MichaReiser MichaReiser added internal An internal refactor or improvement formatter Related to the formatter labels Sep 7, 2023
@MichaReiser MichaReiser force-pushed the add-preview-flag-to-formatter branch 2 times, most recently from 814f4dc to 65c5853 Compare September 8, 2023 09:50
Base automatically changed from add-preview-flag-to-formatter to main September 8, 2023 10:04
@MichaReiser MichaReiser merged commit 0a07a2c into main Sep 8, 2023
16 checks passed
@MichaReiser MichaReiser deleted the extract-string-part branch September 8, 2023 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants