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

editor: Improve rewrapping when working with comments at different indentation levels #18146

Merged
merged 3 commits into from
Sep 20, 2024

Conversation

maxdeviant
Copy link
Member

This PR improves the editor::Rewrap command when working with comments that were not all at the same indentation level.

We now use a heuristic of finding the most common indentation level for each line, using the deepest indent in the event of a tie.

It also removes an .unwrap() that would previously lead to a panic in this case. Instead of unwrapping we now log an error to the logs and skip rewrapping for that selection.

Release Notes:

  • Improved the behavior of editor: rewrap when working with a selection that contained comments at different indentation levels.

@maxdeviant maxdeviant self-assigned this Sep 20, 2024
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Sep 20, 2024
@maxdeviant maxdeviant merged commit 759646e into main Sep 20, 2024
9 checks passed
@maxdeviant maxdeviant deleted the marshall/fix-rewrap-panic branch September 20, 2024 15:45
@maxdeviant
Copy link
Member Author

/cherry-pick v0.154.x

gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Sep 20, 2024
…dentation levels (#18146)

This PR improves the `editor::Rewrap` command when working with comments
that were not all at the same indentation level.

We now use a heuristic of finding the most common indentation level for
each line, using the deepest indent in the event of a tie.

It also removes an `.unwrap()` that would previously lead to a panic in
this case. Instead of unwrapping we now log an error to the logs and
skip rewrapping for that selection.

Release Notes:

- Improved the behavior of `editor: rewrap` when working with a
selection that contained comments at different indentation levels.
maxdeviant added a commit that referenced this pull request Sep 20, 2024
…dentation levels (cherry-pick #18146) (#18147)

Cherry-picked editor: Improve rewrapping when working with comments at
different indentation levels (#18146)

This PR improves the `editor::Rewrap` command when working with comments
that were not all at the same indentation level.

We now use a heuristic of finding the most common indentation level for
each line, using the deepest indent in the event of a tie.

It also removes an `.unwrap()` that would previously lead to a panic in
this case. Instead of unwrapping we now log an error to the logs and
skip rewrapping for that selection.

Release Notes:

- Improved the behavior of `editor: rewrap` when working with a
selection that contained comments at different indentation levels.

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant