ZIm/crates
Smit Barmase 4d79edc753
project: Fix extra } at the end of import on completion accept (#35494)
Closes #34094

Bug in https://github.com/zed-industries/zed/pull/11157

**Context:** 

In https://github.com/zed-industries/zed/pull/31872, we added logic to
avoid re-querying language server completions
(`textDocument/completion`) when possible. This means the list of
`lsp::CompletionItem` objects we have might be stale and not contain
accurate data like `text_edit`, which is only valid for the buffer at
the initial position when these completions were requested. We don't
really care about this because we already extract all the useful data we
need (like insert/replace ranges) into `Completion`, which converts
`text_edit` to anchors. This means further user edits simply push/move
those anchors, and our insert/replace ranges persist for completion
accept.

```jsonc
// on initial textDocument/completion
"textEdit":{"insert":{"start":{"line":2,"character":0},"end":{"line":2,"character":11}},"replace":{"start":{"line":2,"character":0},"end":{"line":2,"character":11}}
```

However, for showing documentation of visible `Completion` items, we
need to call resolve (`completionItem/resolve`) with the existing
`lsp::CompletionItem`, which returns the same `text_edit` and other
existing data along with additional new data that was previously
optional, like `documentation` and `detail`.

**Problem:** 

This new data like `documentation` and `detail` doesn't really change on
buffer edits for a given completion item, so we can use it. But
`text_edit` from this resolved `lsp::CompletionItem` was valid when the
the initial (`textDocument/completion`) was queried but now the
underlying buffer is different. Hence, creating anchors from this ends
up creating them in wrong places.

```jsonc
// calling completionItem/resolve on cached lsp::CompletionItem results into same textEdit, despite buffer edits
"textEdit":{"insert":{"start":{"line":2,"character":0},"end":{"line":2,"character":11}},"replace":{"start":{"line":2,"character":0},"end":{"line":2,"character":11}}
```

It looks like the only reason to override the new text and these ranges
was to handle an edge case with `typescript-language-server`, as
mentioned in the code comment. However, according to the LSP
specification for [Completion
Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion):

> All other properties (usually sortText, filterText, insertText and
textEdit) must be provided in the textDocument/completion response and
**must not be changed during resolve.**

If any language server responds with different `textEdit`, `insertText`,
etc. in `completionItem/resolve` than in `textDocument/completion`, they
should fix that. Bug in this case in `typescript-language-server`:
https://github.com/typescript-language-server/typescript-language-server/pull/303#discussion_r869102064

We don't really need to override these at all. Keeping the existing
Anchors results in correct replacement.

Release Notes:

- Fixed issue where in some cases there would be an extra `}` at the end
of imports when accepting completions.
2025-08-02 03:42:11 +05:30
..
acp_thread agent_ui: More agent notifications (#35441) 2025-08-01 14:29:02 +00:00
activity_indicator Regroup LSP context menu items by the worktree name (#34838) 2025-07-21 17:48:07 +00:00
agent Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
agent_servers Ensure context servers are spawned in the workspace directory (#35271) 2025-07-29 18:03:43 +02:00
agent_settings Replace zed_llm_client with cloud_llm_client (#35309) 2025-07-30 00:09:14 +00:00
agent_ui Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
ai_onboarding Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
anthropic agent: Improve error handling and retry for zed-provided models (#33565) 2025-06-30 21:01:32 -06:00
askpass Revert "git: Intercept signing prompt from GPG when committing" (#34306) 2025-07-11 23:20:35 +00:00
assets Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
assistant_context Replace zed_llm_client with cloud_llm_client (#35309) 2025-07-30 00:09:14 +00:00
assistant_slash_command Stop extensions' servers and message loops before removing their files (#34208) 2025-07-10 19:25:10 +00:00
assistant_slash_commands chore: Bump Rust version to 1.88 (#33439) 2025-06-26 20:54:19 +02:00
assistant_tool Allow edit tool to access files outside project (with confirmation) (#35221) 2025-07-28 14:01:34 -04:00
assistant_tools Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
audio Upgrade rodio to 0.21 (#34368) 2025-07-29 13:24:34 -07:00
auto_update windows: Publish nightly (#24800) 2025-07-09 08:57:03 +08:00
auto_update_helper windows: Publish nightly (#24800) 2025-07-09 08:57:03 +08:00
auto_update_ui Fix documentation of view release notes actions (#33851) 2025-07-03 14:22:28 +00:00
aws_http_client bedrock: Fix remaining streaming delays (#33931) 2025-07-22 11:55:24 -04:00
bedrock bedrock: Fix bedrock not streaming (#28281) 2025-07-01 12:51:09 +03:00
breadcrumbs breadcrumbs: Stylize filename in breadcrumbs when tab-bar is off and file is dirty (#30507) 2025-05-30 08:32:54 -07:00
buffer_diff sum_tree: Store context on cursor (#34904) 2025-07-22 18:20:48 +02:00
call collab: Add screen selector (#31506) 2025-07-21 13:44:51 +02:00
channel Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
cli cli: Remove manual std::io::copy implementation (#34409) 2025-07-15 16:37:15 +02:00
client Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
clock Add the ability to follow the agent as it makes edits (#29839) 2025-05-04 08:28:39 +00:00
cloud_api_client cloud_api_client: Add accept_terms_of_service method (#35452) 2025-08-01 02:50:38 +00:00
cloud_api_types cloud_api_client: Add accept_terms_of_service method (#35452) 2025-08-01 02:50:38 +00:00
cloud_llm_client cloud_api_types: Add more data to the GetAuthenticatedUserResponse (#35384) 2025-07-30 23:38:51 -04:00
collab Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
collab_ui Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
collections Add workspace-hack (#27277) 2025-04-02 13:26:34 -07:00
command_palette Misc code cleanups accumulated while working on other changes (#34787) 2025-07-20 23:22:13 +00:00
command_palette_hooks Add workspace-hack (#27277) 2025-04-02 13:26:34 -07:00
component component preview: Add separators between sections in sidebar (#34701) 2025-07-18 10:24:57 -03:00
context_server Ensure context servers are spawned in the workspace directory (#35271) 2025-07-29 18:03:43 +02:00
copilot Add setting to disable all AI features (#34896) 2025-07-22 11:32:39 -04:00
credentials_provider Add workspace-hack (#27277) 2025-04-02 13:26:34 -07:00
dap debugger: Send initialized event from fake server at a more realistic time (#35446) 2025-07-31 19:45:02 -04:00
dap_adapters debugger: Fix attaching with DebugPy (#34706) 2025-07-18 14:28:03 +00:00
db Misc nitpicks, changes too small / unrelated to be in other PRs (#32768) 2025-06-15 19:51:04 +00:00
debug_adapter_extension Allow remote loading for DAP-only extensions (#33981) 2025-07-06 14:52:16 +02:00
debugger_tools debugger: Improve appearance of session list for JavaScript debugging (#34322) 2025-07-12 15:56:05 +00:00
debugger_ui debugger: Fix not being able to stop a Go debug session when no breakpoints were ever hit (#35190) 2025-07-28 13:14:36 +00:00
deepseek language_models: Emit UsageUpdate events for token usage in DeepSeek and OpenAI (#33242) 2025-06-25 09:42:30 +02:00
diagnostics lsp: Fix workspace diagnostics lag & add streaming support (#34022) 2025-07-15 18:41:45 +03:00
docs_preprocessor docs: Pin mdbook to v0.4.40 (#35380) 2025-07-31 01:34:26 +00:00
editor project: Fix extra } at the end of import on completion accept (#35494) 2025-08-02 03:42:11 +05:30
eval zeta: Add CLI tool for querying edit predictions and related context (#35491) 2025-08-01 21:08:09 +00:00
explorer_command_injector Just Zed instead of Zed Editor (#34146) 2025-07-10 21:08:43 +02:00
extension extension_host: Add npm:install capability (#35144) 2025-07-26 22:40:02 +00:00
extension_api Move language-specific debugging docs to the page for each language (#33692) 2025-07-01 20:02:12 +00:00
extension_cli extension_cli: Copy over snippet file when bundling extensions (#34450) 2025-07-15 11:07:29 +00:00
extension_host Kb/wasm panics (#35319) 2025-07-30 09:18:26 +00:00
extensions_ui ui: Add Chip component (#34521) 2025-07-16 01:15:45 -03:00
feature_flags Add TestPanic feature flag (#34963) 2025-07-23 18:01:16 +00:00
feedback gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
file_finder Allow searching Windows paths with forward slash (#35198) 2025-07-29 17:58:28 +02:00
file_icons Add workspace-hack (#27277) 2025-04-02 13:26:34 -07:00
fs git: Enable git stash in git panel (#32821) 2025-07-25 23:15:54 +00:00
fsevent Add workspace-hack (#27277) 2025-04-02 13:26:34 -07:00
fuzzy editor: Improve code completion filtering to provide fewer and more accurate suggestions (#32928) 2025-06-18 16:01:28 +05:30
git git: Enable git stash in git panel (#32821) 2025-07-25 23:15:54 +00:00
git_hosting_providers git_hosting_providers: Support GitHub remote URLs that start with a slash (#34134) 2025-07-24 18:25:21 -04:00
git_ui onboarding ui: Add theme preview tiles and button functionality to basic page (#35413) 2025-07-31 18:40:41 +00:00
go_to_line Remove into SelectionEffects from .change_selections (#33554) 2025-06-27 14:31:31 -06:00
google_ai Update Gemini Models (#32902) 2025-06-17 20:26:27 +00:00
gpui Rasterize glyphs without D2D (#35376) 2025-08-01 19:46:09 +02:00
gpui_macros gpui: Add use state APIs (#34741) 2025-07-19 01:27:54 +00:00
gpui_tokio Add workspace-hack (#27277) 2025-04-02 13:26:34 -07:00
html_to_markdown agent: Fix crash with pathological fetch output (#34253) 2025-07-11 21:01:09 -04:00
http_client Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
http_client_tls Add workspace-hack (#27277) 2025-04-02 13:26:34 -07:00
icons onboarding: Add design adjustments (#35480) 2025-08-01 15:08:15 -03:00
image_viewer Option to auto-close deleted files with no unsaved edits (#31920) 2025-06-03 13:18:29 +02:00
indexed_docs Stop extensions' servers and message loops before removing their files (#34208) 2025-07-10 19:25:10 +00:00
inline_completion agent: Fix issues with usage display sometimes showing initially fetched usage (#33125) 2025-06-20 21:28:48 +00:00
inline_completion_button Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
inspector_ui Disable minimap in the inspector (#34607) 2025-07-17 09:22:04 +00:00
install_cli gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
jj Add a picker for jj bookmark list (#30883) 2025-05-17 16:42:45 +00:00
jj_ui editor: Improve code completion filtering to provide fewer and more accurate suggestions (#32928) 2025-06-18 16:01:28 +05:30
journal gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
language lsp: Remove Attach enum, default to Shared behaviour (#35248) 2025-07-29 10:07:36 +00:00
language_extension Stop extensions' servers and message loops before removing their files (#34208) 2025-07-10 19:25:10 +00:00
language_model Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
language_models Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
language_selector gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
language_tools Use outlined bolt icon for the LSP tool (#35373) 2025-07-30 21:37:10 -04:00
languages python: Use a single workspace folder for basedpyright (#35292) 2025-07-29 19:00:41 +00:00
livekit_api Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
livekit_client Bump livekit-rust-sdks with another attempt to fix build failures (#35344) 2025-07-31 11:39:46 -04:00
lmstudio lmstudio: Propagate actual error message from server (#34538) 2025-07-25 09:36:43 -04:00
lsp chore: Move a bunch of foreground tasks into background (#35322) 2025-07-30 10:29:03 +00:00
markdown gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
markdown_preview gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
media Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
menu gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
migrator Misc code cleanups accumulated while working on other changes (#34787) 2025-07-20 23:22:13 +00:00
mistral mistral: Add support for magistral-small and magistral-medium (#34983) 2025-07-23 23:13:49 -04:00
multi_buffer Fix panic with completion ranges and autoclose regions interop (#35408) 2025-07-31 16:18:26 +00:00
nc Claude experiment (#34577) 2025-07-17 14:25:55 +00:00
net windows: Add support for SSH (#29145) 2025-07-08 14:34:57 +00:00
node_runtime Replace async-watch with a custom watch (#32245) 2025-06-06 16:00:09 +00:00
notifications sum_tree: Store context on cursor (#34904) 2025-07-22 18:20:48 +02:00
ollama ollama: Add Magistral to Ollama (#35000) 2025-07-24 00:17:54 -04:00
onboarding Add font ligatures and format on save buttons to onboarding UI (#35487) 2025-08-01 17:50:51 -04:00
open_ai open_ai: Make OpenAI error message generic (#33383) 2025-06-28 14:38:27 +02:00
open_router open_router: Fix tool_choice getting serialized to null (#34532) 2025-07-16 11:44:08 -04:00
outline Remove into SelectionEffects from .change_selections (#33554) 2025-06-27 14:31:31 -06:00
outline_panel Add collapse functionality to outline entries (#33490) 2025-07-23 18:52:44 +00:00
panel git panel: Add some design refinements (#34064) 2025-07-08 11:23:36 -03:00
paths paths: Fix using relative path as custom_data_dir (#35256) 2025-07-29 15:31:54 +00:00
picker gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
prettier Shutdown language servers better (#35038) 2025-07-24 15:24:53 +00:00
project project: Fix extra } at the end of import on completion accept (#35494) 2025-08-02 03:42:11 +05:30
project_panel project_panel: Fix autoscroll to treat entries behind sticky items as out of viewport (#35067) 2025-07-25 06:21:38 +05:30
project_symbols Remove into SelectionEffects from .change_selections (#33554) 2025-06-27 14:31:31 -06:00
prompt_store editor: Improve code completion filtering to provide fewer and more accurate suggestions (#32928) 2025-06-18 16:01:28 +05:30
proto Add a field to MultiLSPQuery span showing the current request (#35372) 2025-07-31 22:40:19 +00:00
recent_projects windows: Add support for SSH (#29145) 2025-07-08 14:34:57 +00:00
refineable Add a live Rust style editor to inspector to edit a sequence of no-argument style modifiers (#31443) 2025-05-26 17:43:57 +00:00
release_channel Use shortened SHA when displaying version to install (#31281) 2025-05-23 14:53:53 +00:00
remote chore: Move a bunch of foreground tasks into background (#35322) 2025-07-30 10:29:03 +00:00
remote_server Stop extensions' servers and message loops before removing their files (#34208) 2025-07-10 19:25:10 +00:00
repl editor: Improve minimap performance (#33067) 2025-07-15 00:29:27 +03:00
reqwest_client client: Send User-Agent header on WebSocket connection requests (#35280) 2025-07-29 16:53:56 +00:00
rich_text Add workspace-hack (#27277) 2025-04-02 13:26:34 -07:00
rope sum_tree: Store context on cursor (#34904) 2025-07-22 18:20:48 +02:00
rpc extensions: Add "Debug Adapters" category to the extension store (#32845) 2025-06-17 12:09:08 +02:00
rules_library Remove auto-width editor type (#34438) 2025-07-15 17:36:09 +00:00
schema_generator Add workspace-hack (#27277) 2025-04-02 13:26:34 -07:00
search Fix invalid regular expressions highlighting all search fields (#35001) 2025-07-24 09:20:25 -04:00
semantic_index agent: Disable thinking when using inline assistant/edit file tool (#34141) 2025-07-09 18:05:39 +00:00
semantic_version Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
session Avoid unnecessary DB writes (#29417) 2025-04-25 17:41:49 +03:00
settings Additions for settings profile selector (#35439) 2025-07-31 22:20:35 +00:00
settings_profile_selector Tighten up settings profile selector modal width (#35419) 2025-07-31 17:31:12 +00:00
settings_ui onboarding: Wire up settings import (#35366) 2025-07-30 20:09:11 +00:00
snippet Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
snippet_provider Default `#[schemars(deny_unknown_fields)] for json-language-server schemas (#33883) 2025-07-04 00:57:43 +00:00
snippets_ui gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
sqlez Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
sqlez_macros Add workspace-hack (#27277) 2025-04-02 13:26:34 -07:00
story gpui: Add a standard text example (#30747) 2025-05-16 17:35:44 +02:00
storybook project panel: Add indent guides for sticky items (#34092) 2025-07-09 05:28:25 +05:30
streaming_diff Introduce a new StreamingEditFileTool (#29733) 2025-05-01 17:37:43 +02:00
sum_tree sum_tree: Remove Unit type (#35027) 2025-07-24 14:30:49 +02:00
supermaven gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
supermaven_api supermaven_api: Ensure downloaded Supermaven binary has executable permissions set (#32576) 2025-06-17 14:39:45 +00:00
svg_preview gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
tab_switcher gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
task Add support for Nushell in shell builder (#33806) 2025-07-08 14:57:37 +00:00
tasks_ui Remove into SelectionEffects from .change_selections (#33554) 2025-06-27 14:31:31 -06:00
telemetry Add workspace-hack (#27277) 2025-04-02 13:26:34 -07:00
telemetry_events Add new action to run agent eval (#29158) 2025-04-21 21:30:21 -07:00
terminal Fix incorrect minimum_contrast comment (#34710) 2025-07-18 10:01:09 -04:00
terminal_view terminal_view: Ensure breadcrumbs are updated on settings change (#35016) 2025-07-24 08:51:40 +00:00
text Fix panic with completion ranges and autoclose regions interop (#35408) 2025-07-31 16:18:26 +00:00
theme onboarding: Expand power of theme selector (#35421) 2025-07-31 16:21:58 -04:00
theme_extension Add workspace-hack (#27277) 2025-04-02 13:26:34 -07:00
theme_importer theme_importer: Add missing color imports for the minimap thumb (#34724) 2025-07-18 16:55:03 +00:00
theme_selector Add zed://extension/{id} links (#34492) 2025-07-15 13:42:25 -06:00
time_format agent: Add date separators to Thread History (#29961) 2025-05-06 10:18:48 +00:00
title_bar Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
toolchain_selector gpui: Store action documentation (#33809) 2025-07-02 21:14:33 -04:00
ui onboarding: Add design adjustments (#35480) 2025-08-01 15:08:15 -03:00
ui_input Support multiple OpenAI compatible providers (#34212) 2025-07-22 12:20:07 -03:00
ui_macros Update syn crate from 1.0.109 to 2.0.101 (#31301) 2025-05-23 19:31:25 +00:00
ui_prompt ui_prompt: Fix prompt dialog is hard to see on large screen (#35348) 2025-07-30 23:03:53 +05:30
util Fix Nushell environment variables (#35166) 2025-07-28 13:00:41 -04:00
util_macros Remove separator! macro and make path! handle relative paths (#32527) 2025-06-13 06:32:29 +00:00
vercel vercel: Use proper model identifiers and add image support (#33377) 2025-06-25 13:26:41 +00:00
vim Fix vim cw at end of words (#35300) 2025-07-31 03:48:36 -07:00
vim_mode_setting vim: Fix escape key switching back to default mode instead of normal mode (#31843) 2025-06-18 21:26:12 +00:00
watch chore: Fix warnings for Rust 1.89 (#32378) 2025-06-09 13:11:57 +02:00
web_search Replace zed_llm_client with cloud_llm_client (#35309) 2025-07-30 00:09:14 +00:00
web_search_providers Replace zed_llm_client with cloud_llm_client (#35309) 2025-07-30 00:09:14 +00:00
welcome onboarding ui: Add theme preview tiles and button functionality to basic page (#35413) 2025-07-31 18:40:41 +00:00
workspace Start separating authentication from connection to collab (#35471) 2025-08-01 17:37:38 +00:00
worktree sum_tree: Remove Unit type (#35027) 2025-07-24 14:30:49 +02:00
x_ai Add xAI language model provider (#33593) 2025-07-15 15:35:50 -04:00
zed onboarding: Actions for page navigation (#35484) 2025-08-01 19:30:25 +00:00
zed_actions Introduce settings profiles (#35339) 2025-07-30 21:48:24 +00:00
zeta zeta: Add CLI tool for querying edit predictions and related context (#35491) 2025-08-01 21:08:09 +00:00
zeta_cli zeta: Add CLI tool for querying edit predictions and related context (#35491) 2025-08-01 21:08:09 +00:00
zlog Add meta description tag to docs pages (#35112) 2025-07-29 23:01:03 +00:00
zlog_settings VSCode Settings import (#29018) 2025-04-23 20:54:09 +00:00