kahole / edamagit

Magit for VSCode
https://marketplace.visualstudio.com/items?itemName=kahole.magit
MIT License
1.12k stars 63 forks source link

Multiple vscode windows, one git project: magit.commit opens in wrong window #301

Open the-kenny opened 3 months ago

the-kenny commented 3 months ago

I'm working on a sort-of monorepo where I have multiple projects open in separate vscode windows. The setup is roughly the following:

root/
├── .git/
├── subfolder1/
├── subfolder2/
└── special_subfolder/

Usually, two vscode instances are open: One for root/ (to work on root/ as well as subfolder1/ and subfolder2/) and one for special_subfolder/.

edamagit handles this fairly well: I can simultaneously use it in every window without major hiccups, with one issue:

When I run magic.commit in the vscode instance for special_subfolder/, COMMIT_EDITMSG is opened in the instance for root/, with everything else staying in the instance of special_subfolder/. I expect COMMIT_EDITMSG to open in the instance magic.commit is executed.

Is there a configuration option I missed, or is this an unusual use case that isn't covered (yet)?

If you consider this a bug, would you accept a PR for a fix?

the-kenny commented 3 months ago

Root cause seems to be that GIT_EDITOR is set to "${codePath}" --wait, causing git (in the special_subfolder/ instance) to run code --wait ../.git/COMMIT_EDITMSG. Vscode is smart and recognises this path belonging to the workspace for root/ and opens the file in the instance.

One workaround is to change the command to code --wait --reuse-window . (the . being the most relevant part) which should force vscode to open the path to COMMIT_EDITMSG passed as the next argument in the instance for the current folder.

I'll try this locally and see if there are any unintended side effects and keep you updated.

the-kenny commented 2 months ago

I've been using my fix (https://github.com/kahole/edamagit/pull/302) on macOS for the last two weeks and it seems to work fine without any unintended side effects.