# settings: Fix VS Code import appending duplicate file associations \(\#61355\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/d47347d1aafacf1196eb66d87805592b97864549)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: d47347d1aafacf1196eb66d87805592b97864549

Requested commit: d47347d1aafacf1196eb66d87805592b97864549

Commit: d47347d1aafacf1196eb66d87805592b97864549

Tree: ee1bdae8acc165435e1d9999f632cf104a3307af

Author: Ibrahim Khan

Committer: GitHub

## Message

````
settings: Fix VS Code import appending duplicate file associations (#61355)

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:

```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>
````

## Parents

- [fd8f0cdfd7113ff3a9147db2b0d7a7e33feb6ce5](https://git.cafe/gitcafe/zed/commit/fd8f0cdfd7113ff3a9147db2b0d7a7e33feb6ce5?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/d47347d1aafacf1196eb66d87805592b97864549?format=markdown)
