vscode-gitlens icon indicating copy to clipboard operation
vscode-gitlens copied to clipboard

git commands must often be re-executed in WSL

Open sullivanmj opened this issue 1 year ago • 4 comments

Description

I am using GitLens for VS Code in WSL via the WSL extension. This does not occur when using GitLens on Windows.

Frequently, when I do a command from GitLens that requires a new terminal to be opened, the command does not execute. After a second try, it works. From the terminal output, it looks like it may be the case that GitLens is trying to execute git commands before the terminal prompt has been printed. I don't know if that is the root cause of the problem or not. The initial command appears to be malformed, too.

For example, see this terminal output when I try to force delete a branch via GitLens. I renamed some things to remove references to my actual projects/branch names. What I noticed is that the target branch name was cut in half, and another command was inserted in between it. Note where i've named part of the branch first-part-of-partial-branch-name, and how it has what appears to be a new call to git appended to it. And then last-part-of-partial-branch-name somehow ended up on the line below that. Then, finally the bash prompt is shown. The follow up call appears to be formed correctly and does what I expected it to do.

/usr/bin/git -C "/home/matt/path/to/project.git" -c "core.editor=code --wait --reuse-window" branch --delete --force first-part-of-partial-branch-name/usr/bin/git -C "/home/matt/path/to/project.git" -c "core.editor=code --wait --reuse-window" branch --delete --force full-branch-name
last-part-of-partial-branch-name
matt@MACHINE_NAME:~/path/to/project.git$ 

After executing it a second time, it works, and the command does not appear to be malformed.

This does not appear to be a regression, or at least not a recent one, as this has been happening for quite some time.

GitLens Version

14.6.1

VS Code Version

Version: 1.85.1 (system setup) Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2 Date: 2023-12-13T09:49:37.021Z Electron: 25.9.7 ElectronBuildId: 25551756 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.19045

Git Version

git version 2.34.1

Logs, Screenshots, Screen Captures, etc

No response

sullivanmj avatar Dec 15 '23 17:12 sullivanmj

This feels like a bug in VS Code itself, as GitLens just provides the command that should be executed in the terminal and VS Code handles the rest. Can you please open an issue on the VS Code repository? Thanks!

eamodio avatar Dec 15 '23 23:12 eamodio

OK, agreed. I inserted a long async delay between the call to terminal.show and terminal.sendText, and it works as expected.

sullivanmj avatar Dec 18 '23 17:12 sullivanmj

After searching the vscode issues, I found this: https://github.com/microsoft/vscode/issues/106642. It seems like this is probably what is happening, given the issue author's notes on a way to reproduce:

  1. Programmatically createTerminal let terminal = vscode.window.createTerminal()
  2. Programmatically show Terminal terminal.show();
  3. Programmatically send Text to Terminal terminal.sendText('some command');

Based on the discussion in that issue, it seems the vscode authors can't/won't fix the issue on their end.

sullivanmj avatar Dec 18 '23 17:12 sullivanmj

@sullivanmj Thanks for looking into that -- I would suggest to still open a new issue, while its very similar (and probably the same cause), there might be new options with the terminal integration work that has been done recently.

eamodio avatar Dec 18 '23 18:12 eamodio

This is no longer happening as of some update within the last month or so. Not sure if it was on the GitLens or VS Code side of things.

sullivanmj avatar Mar 22 '24 14:03 sullivanmj

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Apr 22 '24 05:04 github-actions[bot]