Skip to content

settings: Fix VS Code import appending duplicate file associations - #61355

Merged
ChristopherBiscardi merged 2 commits into
zed-industries:mainfrom
IbrahimKhan12:fix/vscode-import-duplicate-file-types
Jul 24, 2026
Merged

settings: Fix VS Code import appending duplicate file associations#61355
ChristopherBiscardi merged 2 commits into
zed-industries:mainfrom
IbrahimKhan12:fix/vscode-import-duplicate-file-types

Conversation

@IbrahimKhan12

@IbrahimKhan12 IbrahimKhan12 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Closes #56536

What & why

Running zed: import vs code settings more than once kept re-adding the same file extensions to file_types, so files.associations entries grew without bound:

"file_types": { "c": ["*.keymap", "*.keymap", "*.keymap"] }

The import merges the VS Code-derived settings into the user's existing settings, and file_types values were ExtendingVecs, whose merge_from appends every incoming value unconditionally.

Per review feedback, instead of changing ExtendingVec's merge semantics (it also backs ssh/wsl connections, private_files, etc.), this adds a new ExtendingSet type that actually behaves like a set, and switches FileTypeMap's file associations to it:

  • Backed by an insertion-order-preserving IndexSet, so users' pattern order round-trips through the settings file unchanged (the import machinery diffs serialized old/new content to produce edits; a sorted set would reorder existing arrays).
  • Merging only accumulates new values, so re-importing an already-present association is a no-op.
  • Since it's a real set, deserialization also collapses duplicates that earlier imports already wrote into the settings file.
  • ExtendingVec and all its other users are untouched.

Testing

  • Added a test_vscode_import case that re-imports an already-present files.associations entry and asserts the extension isn't duplicated. It fails before the change and passes after.
  • cargo test -p settings -p settings_content -p language pass.
  • ./script/clippy -p settings -p settings_content -p language -p recent_projects -p json_schema_store is clean.

Release Notes:

  • Fixed importing VS Code settings repeatedly adding duplicate file_types entries for files.associations.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jul 20, 2026
@IbrahimKhan12
IbrahimKhan12 force-pushed the fix/vscode-import-duplicate-file-types branch from 9618428 to 82d1dc9 Compare July 20, 2026 19:13
@IbrahimKhan12
IbrahimKhan12 marked this pull request as ready for review July 20, 2026 19:13
@ChristopherBiscardi ChristopherBiscardi added the area:settings Feedback for preferences, configuration, etc label Jul 22, 2026
@ChristopherBiscardi

Copy link
Copy Markdown
Contributor

The ExtendingVec is also used in a couple of other locations (such as in remote_connections.rs for ssh/wsl connections), so we need to make sure the change in semantics here doesn't have any adverse impact on those use cases

@ChristopherBiscardi ChristopherBiscardi self-assigned this Jul 22, 2026

@ChristopherBiscardi ChristopherBiscardi 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.

I think we should actually create a new type (ExtendingSet) here that actually behaves like a Set (instead of just behaving like a Set when extending). Then we can use the new ExtendingSet where we want to handle the file associations and leave the wsl/ssh usages of ExtendingVec alone.

@IbrahimKhan12

Copy link
Copy Markdown
Contributor Author

Ack, will look into it.

`zed: import vs code settings` merges VS Code-derived settings into the
existing ones, and `file_types` values were `ExtendingVec`s, whose
merge_from appends unconditionally. Re-running the import therefore grew
`file_types` arrays on every run, e.g. `"c": ["*.keymap", "*.keymap"]`.

Introduce `ExtendingSet`, backed by an insertion-order-preserving
`IndexSet`, and use it for `FileTypeMap`'s file associations. Merging is
idempotent, deserialization collapses duplicates already present in the
settings file, and `ExtendingVec` (still used for ssh/wsl connections,
private files, etc.) keeps its existing semantics.

Closes zed-industries#56536

Release Notes:

- Fixed importing VS Code settings repeatedly adding duplicate `file_types` entries for `files.associations`.
@IbrahimKhan12
IbrahimKhan12 force-pushed the fix/vscode-import-duplicate-file-types branch from 82d1dc9 to 751e55b Compare July 23, 2026 22:08
@IbrahimKhan12

Copy link
Copy Markdown
Contributor Author

Updated to address feedback.

@ChristopherBiscardi ChristopherBiscardi 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.

thanks!

@ChristopherBiscardi
ChristopherBiscardi added this pull request to the merge queue Jul 24, 2026
Merged via the queue into zed-industries:main with commit d47347d Jul 24, 2026
36 checks passed
mdz-axo added a commit to mdz-axo/zed-kask that referenced this pull request Jul 25, 2026
Upstream changes (zed-industries/zed main, 27 commits):
- agent: Add agent.compaction_model setting for context compaction (zed-industries#60012)
- agent: Show effort selector for anthropic compatible providers (zed-industries#61579)
- acp: Update agent-client-protocol SDK to 2.0.0 (zed-industries#61570)
- client: Extract proxy handshakes into new proxy_handshake crate (zed-industries#61427)
- collab: Fix multiworkspace location out of sync bugs (zed-industries#61598)
- editor: Fix sticky header drag cancels autoscroll (zed-industries#53592)
- editor: Fix crash when copying and pasting using multiple cursors (zed-industries#61545)
- editor: Skip untitled buffers when saving a multi-buffer (zed-industries#61380)
- gpui: Fix images not being drawn with rounded corners with ObjectFit::Cover (zed-industries#61383)
- gpui: Fix deadlock in performance profiler and reenable it (zed-industries#61584)
- git_ui: Prevent Git panel bindings in repository selector (zed-industries#61282)
- language_model: Add explicit OpenAI conversation compaction and fix Anthropic compaction (zed-industries#61370)
- markdown: Fix squashed Mermaid diagrams in markdown preview (zed-industries#61260)
- Opus 5 BYOK Support (zed-industries#61596)
- repl: Show add-cell controls in empty notebooks (zed-industries#61329)
- search: Escape seeded buffer search query in regex mode (zed-industries#57748)
- settings: Fix VS Code import appending duplicate file associations (zed-industries#61355)
- settings: Split VSCode and Zed keymap files (zed-industries#61532)
- Treat blank spawn_agent session IDs as absent (zed-industries#60893)
- worktree: Reload git state when a watcher rescan covers a repository (zed-industries#61541)
- Plus 7 more minor fixes.

Merge fixes:
- crates/agent/src/thread.rs: replay_tool_call used 'message_ix' (undefined)
  after auto-merge; renamed to 'owning_message_ix' (the parameter name).
- Cargo.toml: Removed stale workspace members hkask-wallet and hkask-git-cas
  (both directories deleted in prior commits but workspace entries remained).
- kask/crates/hkask-regulation/src/wallet_manager.rs: Stubbed consume() and
  settle_rjoules() on WalletBudgetPort — these were API-key encumbrance
  operations from the deleted hkask-wallet crate; regulation tracks per-agent
  gas balances, not per-key encumbrances.
- kask/crates/hkask-regulation/src/wallet_gas_calibrator.rs: Fixed test to
  use crate::agent_wallet_store::WalletStore instead of hkask_storage::WalletStore.
- kask/crates/hkask-regulation/Cargo.toml: Added tokio macros feature to
  dev-dependencies for #[tokio::test].
- kask/crates/kask_bridge/Cargo.toml: Added futures dependency (needed by
  context_injector.rs for futures::executor::block_on).
- kask/crates/kask_bridge/src/context_injector.rs: Fixed futures_util::executor
  to futures::executor (futures-util doesn't include executor module).

Release Notes:

- N/A
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…ed-industries#61355)

Closes zed-industries#56536

## What & why

Running `zed: import vs code settings` more than once kept re-adding the
same file extensions to `file_types`, so `files.associations` entries
grew without bound:

```json
"file_types": { "c": ["*.keymap", "*.keymap", "*.keymap"] }
```

The import merges the VS Code-derived settings into the user's existing
settings, and `file_types` values were `ExtendingVec`s, whose
`merge_from` appends every incoming value unconditionally.

Per review feedback, instead of changing `ExtendingVec`'s merge
semantics (it also backs ssh/wsl connections, `private_files`, etc.),
this adds a new `ExtendingSet` type that actually behaves like a set,
and switches `FileTypeMap`'s file associations to it:

- Backed by an insertion-order-preserving `IndexSet`, so users' pattern
order round-trips through the settings file unchanged (the import
machinery diffs serialized old/new content to produce edits; a sorted
set would reorder existing arrays).
- Merging only accumulates new values, so re-importing an
already-present association is a no-op.
- Since it's a real set, deserialization also collapses duplicates that
earlier imports already wrote into the settings file.
- `ExtendingVec` and all its other users are untouched.

## Testing

- Added a `test_vscode_import` case that re-imports an already-present
`files.associations` entry and asserts the extension isn't duplicated.
It fails before the change and passes after.
- `cargo test -p settings -p settings_content -p language` pass.
- `./script/clippy -p settings -p settings_content -p language -p
recent_projects -p json_schema_store` is clean.

Release Notes:

- Fixed importing VS Code settings repeatedly adding duplicate
`file_types` entries for `files.associations`.

---------

Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
playdohface pushed a commit to playdohface/zed that referenced this pull request Aug 29, 2026
…ed-industries#61355)

Closes zed-industries#56536

## What & why

Running `zed: import vs code settings` more than once kept re-adding the
same file extensions to `file_types`, so `files.associations` entries
grew without bound:

```json
"file_types": { "c": ["*.keymap", "*.keymap", "*.keymap"] }
```

The import merges the VS Code-derived settings into the user's existing
settings, and `file_types` values were `ExtendingVec`s, whose
`merge_from` appends every incoming value unconditionally.

Per review feedback, instead of changing `ExtendingVec`'s merge
semantics (it also backs ssh/wsl connections, `private_files`, etc.),
this adds a new `ExtendingSet` type that actually behaves like a set,
and switches `FileTypeMap`'s file associations to it:

- Backed by an insertion-order-preserving `IndexSet`, so users' pattern
order round-trips through the settings file unchanged (the import
machinery diffs serialized old/new content to produce edits; a sorted
set would reorder existing arrays).
- Merging only accumulates new values, so re-importing an
already-present association is a no-op.
- Since it's a real set, deserialization also collapses duplicates that
earlier imports already wrote into the settings file.
- `ExtendingVec` and all its other users are untouched.

## Testing

- Added a `test_vscode_import` case that re-imports an already-present
`files.associations` entry and asserts the extension isn't duplicated.
It fails before the change and passes after.
- `cargo test -p settings -p settings_content -p language` pass.
- `./script/clippy -p settings -p settings_content -p language -p
recent_projects -p json_schema_store` is clean.

Release Notes:

- Fixed importing VS Code settings repeatedly adding duplicate
`file_types` entries for `files.associations`.

---------

Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:settings Feedback for preferences, configuration, etc cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Importing files.associations from VS Code leads to duplicate entries

2 participants