Skip to content

VSCode is not set as default editor #1795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ungps opened this issue Aug 16, 2018 · 11 comments
Closed

VSCode is not set as default editor #1795

ungps opened this issue Aug 16, 2018 · 11 comments

Comments

@ungps
Copy link

ungps commented Aug 16, 2018

Hello,

While writing this, I managed to find the problem (check "P.S").

My setup:

$ git --version --build-options
git version 2.18.0.windows.1
cpu: x86_64
built from commit: cd1a74fc9dc8a07626c216940db9a51f25206e03
sizeof-long: 4
cmd.exe /c ver
Microsoft Windows [Version 6.3.9600]
Editor Option: VisualStudioCode
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled

I was trying to add SublimeText and Atom in the list of possible default editors in Git-For-Windows installer. So, I implemented them, made an installer and tried to test it, but it didn't work (by "didn't work" I mean that it installed successfully, both Sublime and Atom could be selected, but neither one of them were added as default editor)... So, I started debugging, although everything seemed alright.

So:

  • I installed Notepad++ and Git-For-Windows (using the official installer) with Notepad++ as default editor. This worked fine.
  • I installed Git-For-Windows (using the official installer) with Nano as default editor. This also worked.
  • I installed Git-For-Windows (using the official installer) with VSCode as default editor. This did not work. By "did not work" I mean that it installed, but VSCode was not the default editor. I looked in the git system configuration file and, indeed, "code.editor" was not set.

P.S: I just looked one more time through registry and observed that:

  • Data of HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\notepad++.exe is:
    C:\Program Files (x86)\Notepad++\notepad++.exe

  • Data of HKLM\SOFTWARE\Classes\Applications\Code.exe\shell\open\command is:
    "C:\Program Files\Microsoft VS Code\Code.exe" "%1"

"%1" is removed from the string at line 1135, but the " at the beginning and at the end of the line are not removed at all. I fixed this, compiled it and now it works. I am going to send a fix for this. I guess that putting your thoughts into words helps debugging. 😄

ungps added a commit to ungps/build-extra that referenced this issue Aug 16, 2018
Selecting VS Code as default editor did not work as
intended. `Git-for-windows` would install successfully,
but `core.editor` option would not be set.

git-for-windows/git#1795

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
@ungps
Copy link
Author

ungps commented Aug 16, 2018

I installed VSCode - Insiders to test it as well and it wasn't even detected by installer. Now it is late, but I hope I will get back to it soon. Until that, I fixed the problem with VS Code and added Sublime Text and Atom as default editors.

git-for-windows/build-extra#200

ungps added a commit to ungps/build-extra that referenced this issue Aug 18, 2018
Selecting VS Code [Insiders] as default editor did not work
as intended. `Git-for-windows` would install successfully,
but `core.editor` option would not be set.

git-for-windows/git#1795

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
@zaaraameera2014
Copy link

No comment

@zaaraameera2014
Copy link

Check ps

ungps added a commit to ungps/build-extra that referenced this issue Aug 31, 2018
Selecting VS Code [Insiders] as default editor did not work
as intended. `Git-for-windows` would install successfully,
but `core.editor` option would not be set.

git-for-windows/git#1795

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
@SteveALee
Copy link

Yup seeing this as well and using the new @code installer and trying to update to G4W 2.19.0

Is there a work around? Can we edit something?

@shiftkey
Copy link

@SteveALee as a workaround you can edit your ~/.gitconfig to set the core.editor value:

@SteveALee
Copy link

@shiftkey well this is strange. During the update install (overwrite older) I selected notepad++ and autocrlf=auto but I see the following in my %USERPROFILE%\.gitconfig

[core]
	editor = code --wait
	autocrlf = true

@shiftkey
Copy link

@SteveALee the installation configuration is applied to the system Git configuration, not your global Git configuration

@illusive-man
Copy link

I think the problem is that couple months back Microsoft has switched to new type of installation distributive which doesn't require admin access in order to install/update VS Code. I believe Git installer is looking for VS Code installed "old way" and obviously just can't find it.

@ghost
Copy link

ghost commented Sep 17, 2018

Also having this issue. Some looking shows VS Code installed at $USERPROFILE/AppData/Local/Programs/Microsoft VS Code. This is now the default because it prevents UAC prompts when installing/updating. Git for Windows should check for VS Code in AppData.

EDIT: I reinstalled VS Code at the system level and Git Setup now gives me the VS Code option, so that's definitely the problem.

EDIT 2: Despite selecting VS Code, the default editor was not set to VS Code. core.editor is unset, leaving the hardcoded default of Vim. I tried installing twice with the same results.

@shiftkey
Copy link

For everyone chiming in:

  • Git for Windows would look at a location under HKEY_LOCAL_MACHINE in the registry, because up until recently VSCode was a machine-wide install by default
  • Around VSCode version 1.26 they changed the install to not require elevation, which means it would install to a new location HKEY_CURRENT_USER for the current user, and Git for Windows doesn't detect that currently
  • On top of the new registry location, there's no "user install" option for Git for Windows, so there's some tricky questions to figure out about how to support this properly over in VS Code, Sublime Text, Atom as text editors build-extra#200 (comment)

@dscho
Copy link
Member

dscho commented Dec 26, 2018

This has been addressed in the meantime. If VS Code is chosen as default editor and that editor is installed user-wide only, the core.editor setting will be adjusted in ~/.gitconfig instead of the system-wide config.

@dscho dscho closed this as completed Dec 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants