Skip to content

project: Don't send context.only for generic code action requests#50979

Merged
SomeoneToIgnore merged 2 commits intozed-industries:mainfrom
loadingalias:gopls-add-test-code-action
Mar 19, 2026
Merged

project: Don't send context.only for generic code action requests#50979
SomeoneToIgnore merged 2 commits intozed-industries:mainfrom
loadingalias:gopls-add-test-code-action

Conversation

@loadingalias
Copy link
Copy Markdown
Contributor

@loadingalias loadingalias commented Mar 7, 2026

Closes #48917

Summary

  • Stop sending context.only for generic textDocument/codeAction requests.
  • Keep explicit kind filtered requests unchanged.
  • Add regression coverage for generic code action requests so actions like source.addTest remain visible.

Root Cause

GetCodeActions::to_lsp populated context.only even when the caller requested all code actions (kinds == None). That turned the normal code actions menu into a filtered request. With gopls, this filtered out source.addTest, so Add test for ... never appeared.

Verification

  • cargo fmt --all -- --check
  • ./script/clippy -p project
  • cargo nextest run -p project --no-fail-fast --no-tests=warn
  • cargo test -p editor editor_tests::test_organize_imports_manual_trigger -- --exact
  • cargo test -p editor editor_tests::test_context_menus_hide_hover_popover -- --exact

Manual Testing

  • Repro'd the protocol level behavior against gopls: unfiltered requests return source.addTest, filtered requests excluding it do not.
  • Opened zed_guild/testing_projects/act/pkg/artifactcache/handler.go
  • Triggered Show Code Actions on StartHandler
  • Confirmed Add test for StartHandler appears

Release Notes:

  • Fixed Go gopls code actions so Add test for ... appears in the generic code actions menu.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 7, 2026
@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Mar 7, 2026
@zelenenka zelenenka added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Mar 19, 2026
Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Thank you!

@SomeoneToIgnore SomeoneToIgnore self-assigned this Mar 19, 2026
@SomeoneToIgnore SomeoneToIgnore enabled auto-merge (squash) March 19, 2026 15:51
@loadingalias
Copy link
Copy Markdown
Contributor Author

You're welcome!

@SomeoneToIgnore SomeoneToIgnore merged commit 783ec44 into zed-industries:main Mar 19, 2026
31 checks passed
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 20, 2026
…d-industries#50979)

Closes zed-industries#48917

## Summary
- Stop sending `context.only` for generic `textDocument/codeAction`
requests.
 - Keep explicit kind filtered requests unchanged.
- Add regression coverage for generic code action requests so actions
like `source.addTest` remain visible.

## Root Cause
`GetCodeActions::to_lsp` populated `context.only` even when the caller
requested all code actions (`kinds == None`). That turned the normal
code actions menu into a filtered request. With `gopls`, this filtered
out `source.addTest`, so `Add test for ...` never appeared.

## Verification
 - `cargo fmt --all -- --check`
 - `./script/clippy -p project`
 - `cargo nextest run -p project --no-fail-fast --no-tests=warn`
- `cargo test -p editor
editor_tests::test_organize_imports_manual_trigger -- --exact`
- `cargo test -p editor
editor_tests::test_context_menus_hide_hover_popover -- --exact`

## Manual Testing
- Repro'd the protocol level behavior against `gopls`: unfiltered
requests return `source.addTest`, filtered requests excluding it do not.
 - Opened `zed_guild/testing_projects/act/pkg/artifactcache/handler.go`
 - Triggered `Show Code Actions` on `StartHandler`
 - Confirmed `Add test for StartHandler` appears


Release Notes:

- Fixed Go `gopls` code actions so `Add test for ...` appears in the
generic code actions menu.

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
toshmukhamedov pushed a commit to toshmukhamedov/zed that referenced this pull request Mar 20, 2026
…d-industries#50979)

Closes zed-industries#48917

## Summary
- Stop sending `context.only` for generic `textDocument/codeAction`
requests.
 - Keep explicit kind filtered requests unchanged.
- Add regression coverage for generic code action requests so actions
like `source.addTest` remain visible.

## Root Cause
`GetCodeActions::to_lsp` populated `context.only` even when the caller
requested all code actions (`kinds == None`). That turned the normal
code actions menu into a filtered request. With `gopls`, this filtered
out `source.addTest`, so `Add test for ...` never appeared.

## Verification
 - `cargo fmt --all -- --check`
 - `./script/clippy -p project`
 - `cargo nextest run -p project --no-fail-fast --no-tests=warn`
- `cargo test -p editor
editor_tests::test_organize_imports_manual_trigger -- --exact`
- `cargo test -p editor
editor_tests::test_context_menus_hide_hover_popover -- --exact`

## Manual Testing
- Repro'd the protocol level behavior against `gopls`: unfiltered
requests return `source.addTest`, filtered requests excluding it do not.
 - Opened `zed_guild/testing_projects/act/pkg/artifactcache/handler.go`
 - Triggered `Show Code Actions` on `StartHandler`
 - Confirmed `Add test for StartHandler` appears


Release Notes:

- Fixed Go `gopls` code actions so `Add test for ...` appears in the
generic code actions menu.

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
@JosephTLyons JosephTLyons moved this to Shipped by the Guild in Zed Guild - The Board Mar 20, 2026
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 23, 2026
…d-industries#50979)

Closes zed-industries#48917

## Summary
- Stop sending `context.only` for generic `textDocument/codeAction`
requests.
 - Keep explicit kind filtered requests unchanged.
- Add regression coverage for generic code action requests so actions
like `source.addTest` remain visible.

## Root Cause
`GetCodeActions::to_lsp` populated `context.only` even when the caller
requested all code actions (`kinds == None`). That turned the normal
code actions menu into a filtered request. With `gopls`, this filtered
out `source.addTest`, so `Add test for ...` never appeared.

## Verification
 - `cargo fmt --all -- --check`
 - `./script/clippy -p project`
 - `cargo nextest run -p project --no-fail-fast --no-tests=warn`
- `cargo test -p editor
editor_tests::test_organize_imports_manual_trigger -- --exact`
- `cargo test -p editor
editor_tests::test_context_menus_hide_hover_popover -- --exact`

## Manual Testing
- Repro'd the protocol level behavior against `gopls`: unfiltered
requests return `source.addTest`, filtered requests excluding it do not.
 - Opened `zed_guild/testing_projects/act/pkg/artifactcache/handler.go`
 - Triggered `Show Code Actions` on `StartHandler`
 - Confirmed `Add test for StartHandler` appears


Release Notes:

- Fixed Go `gopls` code actions so `Add test for ...` appears in the
generic code actions menu.

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

Status: Shipped by the Guild

Development

Successfully merging this pull request may close these issues.

"Add test" code action not appearing with gopls

4 participants