glacambre / firenvim

Embed Neovim in Chrome, Firefox & others.
GNU General Public License v3.0
4.68k stars 144 forks source link

fix: reset s:is_wsl after calling (un)install #1628

Closed xudyang1 closed 1 month ago

xudyang1 commented 1 month ago

The behaviors of firenvim#install and firenvim#uninstall on WSL are controlled by the script variable s:is_wsl: we initialize it to false to (un)install firenvim on wsl side, and then set it to 1 to (un)install on windows host side.

Currently, only firenvim#install and firenvim#uninstall changes the value of s:is_wsl. The two function do not reset s:is_wsl, and thus s:is_wsl is always 1 after calling them.

As a result, doing the followings sequentially in neovim have unexpected results:

-- 1. `s:is_wsl` is set to 1
vim.fn["firenvim#install"](0)

-- 2. uninstall firenvim only on windows host because `s:is_wsl` is 1
vim.fn["firenvim#uninstall"]()
-- 1. `s:is_wsl` is set to 1
vim.fn["firenvim#uninstall"]()
-- 2. reinstall, installs scripts on host only, no scripts on WSL
vim.fn["firenvim#install"](0)

To fix this, a try ... finally block resets s:is_wsl even if the two functions throw errors or run unsuccessfully.

glacambre commented 1 month ago

Thanks! Sorry for the late merge - I'm a bit distracted.

xudyang1 commented 1 month ago

Thanks! Sorry for the late merge - I'm a bit distracted.

No worries.