Skip to content

Honor EditorConfig levels for unused-include diagnostics - #14858

Merged
Colen Garoutte-Carson (Colengms) merged 5 commits into
mainfrom
dev/coleng/include-dimming-parity
Nov 12, 2026
Merged

Colen Garoutte-Carson (Colengms) merged 5 commits into
mainfrom
dev/coleng/include-dimming-parity

Conversation

@Colengms

@Colengms Colen Garoutte-Carson (Colengms) commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

The extension forwarded Include Cleanup filtering rules but omitted the unused-include diagnostic level, preventing the native server from honoring that preference.

Forward cpp_include_cleanup_remove_unused_error_tag_type with each file's Include Cleanup preferences. Missing or unset values default to none, and diagnostic-level values are case-insensitive.

Include localized messages for unused and duplicate includes, plus unit coverage for defaults, supported levels, casing, and unset handling.

Fix EditorConfig precedence and refresh behavior so closer opt-outs and edits to applicable configs outside workspace folders take effect.

A companion native-side PR exists in a private repository.

Related to: #14857

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

No active review issues are recorded for the change forwarding the unused-include diagnostic level to the native server.

No open issues 🎉

What changed in this PR

This PR adds the unused-include diagnostic level to the Include Cleanup preferences sent to the native server, allowing it to honor the per-file EditorConfig setting.

Changes:

  • Forward cpp_include_cleanup_remove_unused_error_tag_type, normalizing casing and defaulting missing or unset values to none.
  • Add localizable diagnostic messages for unused and duplicate includes.
  • Extend unit coverage for defaults, supported levels, casing, and unset handling.
File Description
Extension/​test/​unit/​includeCleanupEditorConfig.test.ts Tests diagnostic-level forwarding and normalization.
Extension/​src/​nativeStrings.json Adds unused-include and duplicate-include diagnostic strings.
Extension/​src/​LanguageServer/​includeCleanupEditorConfig.ts Includes the normalized diagnostic level in cleanup preferences.

Review effort: Balanced

@Colengms
Colen Garoutte-Carson (Colengms) marked this pull request as ready for review November 6, 2026 21:34
@sean-mcmanus

Sean McManus (sean-mcmanus) commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Colen Garoutte-Carson (@Colengms) It would help if you mentioned in the description that there was a matching VS repo PR. devbox2-wsl/agent656 is the agent reviewing the VS repo PR (so it found this PR from the link there), and devbox4-wsl/agent66 is the agent that I assigned to review this PR thinking that it didn't have an associated VS repo PR.

Honor later sections and closer configuration files so local
preferences override inherited settings. Refresh applicable
configuration outside workspace folders without recursive watches,
and release watches when their documents are no longer visible.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Colengms

Copy link
Copy Markdown
Contributor Author

Sean McManus (@sean-mcmanus) Added a note that a companion native-side PR exists. The public description intentionally contains no private-repository links.

Written by Copilot

Comment thread Extension/src/LanguageServer/client.ts Resolved
Comment thread Extension/CHANGELOG.md Resolved

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.

🟡 Changes recommended

Secondary workspace clients can retain ancestor watches after files are hidden or closed because visibility updates reach only the default client, causing duplicate watches and refresh callbacks.

1 open issue

Review effort: Balanced

Comment thread Extension/src/LanguageServer/client.ts Resolved
Discard winning unset values after configuration inheritance
without restoring ancestor settings. Apply text options using
the active document resource and keep ancestor watchers owned by
the default client. Remove the release-note placeholder.

Co-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.

🔵 Needs a closer look

EditorConfig watches are not restored when workspace folders are removed or clients recover from crashes, allowing subsequent configuration edits to leave preferences and diagnostics stale.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Client recreation fails to restore visible-editor watches

Extension/​src/​LanguageServer/​client.ts:1953

After a language-server crash, ClientCollection.recreateClients() disposes the old client and its watchers, but restores documents through sendDidOpen() and didChangeActiveEditor(), neither of which calls prepareVisibleEditorInfo(). If the visible editors remain unchanged, the replacement client never recreates these watches, so subsequent edits to external .editorconfig files stop refreshing preferences until visibility changes. Reinitialize the default client's watcher from the current visible editors during crash recovery, or preserve watcher ownership across client recreation.

Medium severity Workspace folder changes leave visible-editor watches stale

Extension/​src/​LanguageServer/​editorConfig.ts:212

Removing a secondary workspace folder while its C++ editor stays visible leaves that folder unwatched: these directories were skipped, and the workspace watcher no longer covers them. Subsequent .editorconfig edits can leave preferences and diagnostics stale because the workspace-folder handler transfers document ownership without updating visible-editor state. Recompute the default client's ancestor watches and refresh preferences when workspace folders change.

1 resolved since last review

Review effort: Balanced

Keep external EditorConfig preferences current after client recreation
and workspace-folder changes even when visible editors do not change.
Cover both lifecycle paths in the existing multi-root scenario suite.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Colengms

Copy link
Copy Markdown
Contributor Author

Addressed both previously missed findings from the latest review in 500c831:

  • Client recreation restores external EditorConfig watches even when visible editors do not change.
  • Workspace-folder changes refresh visible-editor preferences and watch coverage, including a removed folder whose C++ editor remains visible.

Both regressions failed before the fix and pass in a real multi-root VS Code host afterward. The existing EditorConfig tests, TypeScript build, and targeted lint also pass. No changelog or native binary-version-gate change is included.

Written by Copilot

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.

🟡 Changes recommended

The test calls recreateClients() outside the crash/restart lifecycle, so disposing the old default client removes shared providers and the workspace watcher without restoring them, leaving subsequent tests with a partially disabled extension host.

1 open issue

Review effort: Balanced

Exercise ClientCollection recreation with isolated client stubs instead
of disposing the extension host's live shared providers. Preserve the
watcher-restoration assertion without disabling later feature tests.

Co-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.

🔵 Needs a closer look

The new wire fields and localized diagnostic IDs depend on an unavailable private native-side companion, leaving their cross-repository contract and end-to-end diagnostic behavior unvalidated.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@Colengms
Colen Garoutte-Carson (Colengms) merged commit 6661b65 into main Nov 12, 2026
7 checks passed
@Colengms
Colen Garoutte-Carson (Colengms) deleted the dev/coleng/include-dimming-parity branch November 12, 2026 19:07
@github-project-automation github-project-automation Bot moved this from Pull Request to Done in cpptools Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants