Skip to content

Exclude trailing inline comments from comment runs - #2255

Merged
Christoph Bergmeister (bergmeister) merged 1 commit into
copilot/fix-psuseconsistentindentation-issuefrom
copilot/fix-trailing-comment-run
Oct 27, 2026
Merged

Christoph Bergmeister (bergmeister) merged 1 commit into
copilot/fix-psuseconsistentindentation-issuefrom
copilot/fix-trailing-comment-run

Conversation

@bergmeister

Copy link
Copy Markdown
Collaborator

PR Summary

Exclude trailing inline comments from comment-run detection so following standalone comments retain the correct indentation. Add a regression test for the case.

Local build could not run: the required .NET 8 SDK is unavailable, and package restore from the configured Azure feed returned 401.

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • Change is not breaking
  • Existing source file copyright headers are unchanged
  • Added a regression test
  • This PR is ready to merge and is not Work in Progress.
Add a regression test for standalone comments following trailing inline comments.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Static review found no blocking issues in this focused fix and regression test, though build and runtime tests were not run.

No open issues 🎉

What changed in this PR

This PR fixes comment-run detection in the indentation formatter so trailing inline comments do not affect the indentation of following standalone comments.

Changes:

  • Stop backward comment-run scanning when a comment has preceding code on the same line.
  • Add a regression test confirming that the inline comment remains unchanged while the standalone comment is correctly indented.
File Description
Tests/​Rules/​UseConsistentIndentation.tests.ps1 Adds regression coverage for standalone comments following an inline comment.
Rules/​UseConsistentIndentation.cs Detects preceding same-line code and excludes inline comments from comment runs.

Review effort: Balanced

@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 27, 2026 17:25
@bergmeister
Christoph Bergmeister (bergmeister) merged commit 91e54c2 into copilot/fix-psuseconsistentindentation-issue Oct 27, 2026
8 checks passed
@bergmeister
Christoph Bergmeister (bergmeister) deleted the copilot/fix-trailing-comment-run branch October 27, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants