Skip to content

Make completion behavior configurable (unimported namespaces, name suggestions) - #425

Draft
razzmatazz wants to merge 7 commits into
mainfrom
completion-unimported-namespaces-config
Draft

razzmatazz wants to merge 7 commits into
mainfrom
completion-unimported-namespaces-config

Conversation

@razzmatazz

@razzmatazz razzmatazz commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Adds a hierarchical csharp.completion.* configuration group for tuning Roslyn completion behavior that was previously hardcoded:
    • csharp.completion.completeUnimportedTypes (default true) — suggest types from namespaces not yet imported, and insert the missing using (via additionalTextEdits) when one of those items is accepted. Closes Autoimport with code suggestion. #210
    • csharp.completion.showNameSuggestions (default false) — suggest identifier names (e.g. stringBuilder after typing StringBuilder )
  • Both flags were previously hardcoded (ShowItemsFromUnimportedNamespaces = false, ShowNameSuggestions = false); defaults now restore/preserve prior UX where sensible while making both configurable for users who hit latency issues on large solutions
  • completionItem/resolve now calls CompletionService.GetChangeAsync for completion items Roslyn marks IsComplexTextEdit (e.g. unimported-namespace items) and forwards every resulting TextChange other than the item's own in-place replacement as AdditionalTextEdits, so accepting such an item also adds the required using — previously only textDocument/codeAction could add it
  • Refactors option-building into a single getRoslynCompletionOptions helper shared by both the .cs and .cshtml (Razor) completion code paths
  • Adds regression tests covering default/explicit behavior for both settings and the new using-insertion behavior, plus supporting fixtures

Closes #210

🤖 Generated with ECA (anthropic/claude-sonnet-5)

@razzmatazz razzmatazz changed the title Make completion suggestions from unimported namespaces configurable, default on Make completion behavior configurable (unimported namespaces, name suggestions) Sep 13, 2026
razzmatazz and others added 4 commits September 13, 2026 16:07
…rable, default on

Adds `csharp.completionShowItemsFromUnimportedNamespaces` to re-enable
Roslyn's "show items from unimported namespaces" completion behavior,
which was previously hardcoded off for performance reasons. The setting
defaults to `true`; users on large solutions who hit latency issues can
opt back out.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-sonnet-5)

Co-Authored-By: eca-agent <git@eca.dev>
…n.* and add showNameSuggestions

Reworks the flat `csharp.completionShowItemsFromUnimportedNamespaces` setting
into a hierarchical `CSharpCompletionConfiguration` (mirroring the existing
`csharp.debug.*` group), exposed as `csharp.completion.showItemsFromUnimportedNamespaces`.

Also adds `csharp.completion.showNameSuggestions` to control Roslyn's
"show name suggestions" completion behavior, defaulting to `false` to match
the previous hardcoded value.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-sonnet-5)

Co-Authored-By: eca-agent <git@eca.dev>
…space completion item

Renames `csharp.completion.showItemsFromUnimportedNamespaces` to
`csharp.completion.completeUnimportedTypes` to reflect that it now controls
both aspects together: showing the item in the completion list *and*
inserting the missing `using` (as `additionalTextEdits`) when the item is
accepted, instead of leaving the import to be added separately via
`textDocument/codeAction`.

Roslyn already marks such items `IsComplexTextEdit = true`; on
`completionItem/resolve` we now call `CompletionService.GetChangeAsync` for
those items and forward every resulting `TextChange` other than the item's
own in-place replacement as `AdditionalTextEdits`. Plain (non-complex)
completion items are unaffected.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-sonnet-5)

Co-Authored-By: eca-agent <git@eca.dev>
@razzmatazz
razzmatazz force-pushed the completion-unimported-namespaces-config branch from d22cd7a to cb1a5b4 Compare September 13, 2026 13:07
State the `<type>(<scope>): <summary>` scheme directly instead of only
linking to CONTRIBUTING.md#code-style, so it isn't missed when committing.
razzmatazz added a commit that referenced this pull request Sep 13, 2026
Analyses why textDocument/completion responses balloon to multi-megabyte
payloads on every keystroke once unimported-namespace suggestions
(completion-unimported-namespaces-config, PR #425) are enabled: handle
hardcodes IsIncomplete = true, so VS Code re-requests the full unimported
symbol universe on every character instead of filtering the existing list
locally. Proposes fixing that first, with debouncing/caching only if
profiling shows per-call cost (not repetition) is still the bottleneck.
Plans and other persisted docs sometimes draw on a real session against a
user's private solution; capture the standing rule to swap in fictional
namespaces/types/file names before committing, keeping this project's own
public identifiers exempt.
Roslyn's CompletionList has no incompleteness concept of its own (verified
by reflecting over the actual Microsoft.CodeAnalysis.Features assembly this
project builds against - no member resembling "there's more, ask again") -
it always returns its full candidate set for the current cursor context in
one call, expecting the client to filter by filterText as the user keeps
typing. Hardcoding IsIncomplete = true here instead made editors re-request
the full list - including the unimported-namespace scan - via
TriggerForIncompleteCompletions on every keystroke, turning one legitimate
completion session into a fresh multi-megabyte recomputation per character
typed on large solutions.

Update CompletionTests.fs's assertion, which previously codified the old
(incorrect) behavior.
@razzmatazz
razzmatazz force-pushed the completion-unimported-namespaces-config branch from 79b18d2 to 9ba6135 Compare September 13, 2026 14:11
@razzmatazz
razzmatazz marked this pull request as draft October 5, 2026 06:25
@razzmatazz razzmatazz added bug Something isn't working and removed bug Something isn't working labels Oct 21, 2026
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.

Autoimport with code suggestion.

1 participant