natecraddock / workspaces.nvim

a simple plugin to manage workspace directories in neovim
MIT License
309 stars 15 forks source link

[Bug] Removing a workspace by name accidentally removes the workspace at the current directory #28

Closed tobias-haenel closed 9 months ago

tobias-haenel commented 9 months ago

Removing a workspace by executing :WorkspacesRemove WS_NAME, sometimes removes the workspace with the path to the current working directory.

The bug seems to be at line 293 in remove_workspace_or_directory https://github.com/natecraddock/workspaces.nvim/blob/a6fb4995333f927cc6f707890800fa7f7c476043/lua/workspaces/init.lua#L291-L314

  1. path is set to current working directory even if name is not nil
  2. find returns a workspace whose path matches the current working directory
  3. The wrong workspace gets removed

Proposed fix: Change line 293 to

local path = (not name and cwd()) or nil
natecraddock commented 9 months ago

Nice catch! Thanks for looking into this, and for providing a fix. I tested it locally and it works great. I just pushed a commit to resolve this!