# windows: Fix extension uninstall \(\#18467\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 9f72e05c4056ff6514660276e3e33e8757c674d6

Requested commit: 9f72e05c4056ff6514660276e3e33e8757c674d6

Commit: 9f72e05c4056ff6514660276e3e33e8757c674d6

Tree: 374964c0c054298892cfba581e08d28ed1452485

Author: 张小白

Committer: GitHub

## Message

```
windows: Fix extension uninstall (#18467)

Closes #18153


When calling `uninstall_extension`, the `work_dir` associated with this
`extension` doesn't have its corresponding `FileHandle` properly closed,
preventing the deletion of the `work_dir`. As seen in the image below,
after installing the `toml` extension, `zed.exe` holds two `Handle`s for
the folder `C:\Users\36477\AppData\Local\Zed\extensions\work\toml`.

![Screenshot 2024-09-27
171149](https://github.com/user-attachments/assets/f75f3f6f-9a62-43b5-9450-73ee1ed8e7f9)


Therefore, after deleting `extension_dir` and then calling
`this.update(...)`, `zed.exe` releases these two `Handles`, and only
then can the folder
`C:\Users\36477\AppData\Local\Zed\extensions\work\toml` be deleted. See
the corresponding file handles are closed after calling
`this.update(...)`:

![Screenshot 2024-09-28
132823](https://github.com/user-attachments/assets/476e0494-850a-4af5-b351-899e60ae98f7)

However, if there is a running server of the extension, the error will
persist. At this point, I haven’t found a direct way to terminate all
running servers of the extension. Since this feature might affect the
`LspStore` structure, I paused my work here.


See when `toml` extension is running, we can not delete
`C:\Users\36477\AppData\Local\Zed\extensions\work\toml` since
`C:\Users\36477\AppData\Local\Zed\extensions\work\toml\taplo.exe` is
still running:

![Screenshot 2024-09-28
134709](https://github.com/user-attachments/assets/6801d6e2-2a44-4103-8570-467c507e6e20)



cc @ConradIrwin You're the expert in this area—what are your thoughts?



Release Notes:

- N/A
```

## Parents

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

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