Skip to content

fix: remove newline when removing unused import#54

Merged
AJenbo merged 1 commit intoAJenbo:mainfrom
calebdw:calebdw/push-wrtqupuyprys
Mar 31, 2026
Merged

fix: remove newline when removing unused import#54
AJenbo merged 1 commit intoAJenbo:mainfrom
calebdw:calebdw/push-wrtqupuyprys

Conversation

@calebdw
Copy link
Copy Markdown
Contributor

@calebdw calebdw commented Mar 30, 2026

Closes #50

Note that I basically just had gpt-5.4 take a crack at it, so feel free to update as you see fit. I did test it out and it fixed the issue

Best,

AJenbo added a commit to calebdw/phpantom_lsp that referenced this pull request Mar 31, 2026
When removing unused imports, the blank line separating the import block
from the class body was left behind. The deletion edit now consumes
adjacent blank lines intelligently:

- When the entire import block is removed, the trailing separator line
  is consumed so no stray blank line remains before the class.
- When an import between two groups is removed, the doubled blank line
  is collapsed into one.
- When imports remain on both sides of a gap, the gap is preserved.

The edit builder receives a set of all lines being removed so that bulk
removal can reason about which imports will survive after the operation.

Closes AJenbo#50
Contributed by @calebdw in AJenbo#54
@AJenbo AJenbo force-pushed the calebdw/push-wrtqupuyprys branch from 530a53b to eb0f9fa Compare March 31, 2026 14:14
When removing unused imports, the blank line separating the import block
from the class body was left behind. The deletion edit now consumes
adjacent blank lines intelligently:

- When the entire import block is removed, the trailing separator line
  is consumed so no stray blank line remains before the class.
- When an import between two groups is removed, the doubled blank line
  is collapsed into one.
- When imports remain on both sides of a gap, the gap is preserved.

The edit builder receives a set of all lines being removed so that bulk
removal can reason about which imports will survive after the operation.

Closes AJenbo#50
Contributed by @calebdw in AJenbo#54
@AJenbo AJenbo force-pushed the calebdw/push-wrtqupuyprys branch from eb0f9fa to 8a88190 Compare March 31, 2026 14:18
@AJenbo AJenbo merged commit d861c9c into AJenbo:main Mar 31, 2026
4 of 5 checks passed
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.51477% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.80%. Comparing base (110a5c4) to head (8a88190).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/code_actions/remove_unused_import.rs 94.51% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #54      +/-   ##
==========================================
+ Coverage   87.78%   87.80%   +0.02%     
==========================================
  Files         144      144              
  Lines       82890    83117     +227     
==========================================
+ Hits        72762    72978     +216     
- Misses      10128    10139      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@calebdw calebdw deleted the calebdw/push-wrtqupuyprys branch March 31, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: code action "remove all unused imports" should also remove new line

3 participants