Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Respect inactive region column offsets when applying decorations - #14666

Closed
Prashant Kumar Rai (8prashant) wants to merge 1 commit into
microsoft:mainfrom
8prashant:prashant-fix-inactive-region-columns
Closed

Respect inactive region column offsets when applying decorations#14666
Prashant Kumar Rai (8prashant) wants to merge 1 commit into
microsoft:mainfrom
8prashant:prashant-fix-inactive-region-columns

Conversation

@8prashant

Copy link
Copy Markdown
Contributor

Summary

Fixes #12882

This change updates inactive-region decoration ranges to preserve the column offsets reported by the IntelliSense engine.

Previously, inactive regions were converted to whole-line VS Code ranges by forcing both start and end columns to 0. That caused lines containing active text before a preprocessor directive, such as a leading comment before #if 0, to be dimmed incorrectly.

The decoration range now uses startColumn and endColumn when they are present, while preserving the existing line-based fallback behavior for responses that do not include column data.

Changes

  • Added optional startColumn and endColumn fields to InputRegion.
  • Updated inactive-region decoration creation to use the reported start/end columns.
  • Kept 0 as the fallback column value for compatibility with line-only inactive region data.

Testing

Tested locally on Windows.

  • yarn compile
  • yarn lint
  • yarn test
  • git diff --check

Also manually verified in an isolated Extension Development Host using a repro case where a comment precedes #if 0 on the same line. The comment remains active while the inactive block is dimmed.

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.

Pull request overview

Preserves IntelliSense-provided column offsets when rendering inactive regions.

Changes:

  • Adds optional start/end columns to InputRegion.
  • Uses column offsets with backward-compatible zero-column fallbacks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Colengms

Copy link
Copy Markdown
Contributor

Hi Prashant Kumar Rai (@8prashant) . Thanks for the contribution! The native component of the C/C++ Extension doesn't currently pass down startColumn and endColumn in InputRegion. I went ahead and made the corresponding changes to the native side. We can use this PR, if you'd like to remove the ? and undefined checks. (They will always be present, with my native-side changes). Or I could make the TypeScript-side adjustments myself in a new PR and you could abandon this one.

@Colengms

Copy link
Copy Markdown
Contributor

Hi Prashant Kumar Rai (Prashant Kumar Rai (@8prashant)) . Thanks for the contribution! The native component of the C/C++ Extension doesn't currently pass down startColumn and endColumn in InputRegion. I went ahead and made the corresponding changes to the native side. We can use this PR, if you'd like to remove the ? and undefined checks. (They will always be present, with my native-side changes). Or I could make the TypeScript-side adjustments myself in a new PR and you could abandon this one.

Actually, I needed to make another minor change, so I created: #14667

We can abandon this PR. This change should make it into 1.34.0

@sean-mcmanus

Copy link
Copy Markdown
Contributor

Prashant Kumar Rai (@8prashant) Fixed in https://github.com/microsoft/vscode-cpptools/releases/tag/v1.34.0 (pre-release).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pull Request

Development

Successfully merging this pull request may close these issues.

Incorrect inactive region when preprocessor directive is preceded by a comment

5 participants