Skip to content

[ty] Fix folding ranges of comments separated by statements#24132

Merged
MichaReiser merged 2 commits intomainfrom
micha/fix-folding-comments
Mar 23, 2026
Merged

[ty] Fix folding ranges of comments separated by statements#24132
MichaReiser merged 2 commits intomainfrom
micha/fix-folding-comments

Conversation

@MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Mar 23, 2026

Summary

I rewrote the comment folding in #23831 to use comment ranges instead of iterating over the file's range.
However, I failed to account for the case where two comments are separated by statements.

This PR groups comments together only when they're separated by whitespace.

Fixes astral-sh/ty#3106

Test Plan

Added regression test

Screen.Recording.2026-03-23.at.12.10.43.mov

@MichaReiser MichaReiser added the bug Something isn't working label Mar 23, 2026
@MichaReiser MichaReiser requested a review from sharkdp as a code owner March 23, 2026 10:12
@MichaReiser MichaReiser added the server Related to the LSP server label Mar 23, 2026
@astral-sh-bot astral-sh-bot bot added the ty Multi-file analysis & type inference label Mar 23, 2026
@MichaReiser MichaReiser marked this pull request as draft March 23, 2026 10:13
@MichaReiser MichaReiser force-pushed the micha/fix-folding-comments branch 4 times, most recently from 9105113 to 0b3f5f1 Compare March 23, 2026 10:17
@MichaReiser MichaReiser marked this pull request as ready for review March 23, 2026 10:17
@MichaReiser MichaReiser force-pushed the micha/fix-folding-comments branch from 0b3f5f1 to 8bfeacd Compare March 23, 2026 10:34
@AlexWaygood AlexWaygood removed their request for review March 23, 2026 10:43
@MichaReiser MichaReiser merged commit 4df70f4 into main Mar 23, 2026
46 checks passed
@MichaReiser MichaReiser deleted the micha/fix-folding-comments branch March 23, 2026 14:42
carljm added a commit that referenced this pull request Mar 25, 2026
* main: (36 commits)
  [ty] Reduce diagnostic range for `invalid-metaclass` (#24145)
  [ty] Simplify TypeVar assignability/subtyping logic (#24138)
  [ty] Prevent tainted loop bindings in cycle normalization (#24143)
  [ty] Add precisely-typed overloads for `TypedDict` update (#24101)
  [ty] Fix folding ranges of comments separated by statements (#24132)
  Bump ecosystem-analyzer pin (#24136)
  Bump ecosystem-analyzer pin (#24135)
  Simplify `NewType` handling in `relation.rs` (#24109)
  [ty] Add more tests for `NewType` subtyping (#24115)
  [ty] Add `NewType`s to the property tests (#24113)
  [ty] Prepare test files for unreachable code change (#24133)
  `analyze graph`: resolve string imports that reference attributes, not just modules (#24058)
  Update Artifact GitHub Actions dependencies (#24116)
  Update taiki-e/install-action action to v2.68.33 (#24130)
  Update taiki-e/install-action action to v2.68.32 (#24123)
  Update Rust crate serde_with to v3.18.0 (#24126)
  Update Swatinem/rust-cache action to v2.9.1 (#24127)
  Update Rust crate quick-junit to 0.6.0 (#24125)
  Update Rust crate clap to v4.6.0 (#24124)
  Update Rust crate tracing-subscriber to v0.3.23 (#24122)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working server Related to the LSP server ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comment folding is inconsistent

3 participants