-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Up For Grabs: detect whether VS Code is available, and offer it as editor option in that case #1356
Comments
Just reading along here.. This sound like a great task for someone to have a go at. One query.. In the beginning section that says "simply (of the registry entry) replace the trailing Now I type that out, it feels more obvious that it is the 'alternatively' choice.. doh. |
Thanks for your feedback @PhilipOakley
Exactly. I just edited the confusing text, hopefully the new version is better? |
I have done an initial fork, with a check-in under missing is substitute the trailing "%1" by --wait can someone help with that? |
Yes: in igorlino/build-extra@07c9182#diff-9db0b81cc5d2dc9d49e4e8634ac624b6R1086, you set the if (RdbEditor[GE_VisualStudioCode].Enabled) then
StringChangeEx(VisualCodePath,' "%1"','',True); This will strip the Then, you will want to replace the Notepad++-specific options (such as |
Closed via git-for-windows/build-extra#164 |
The Git for Windows installer [now offers to configure Visual Studio Code as default editor for Git](git-for-windows/git#1356). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
There are now so many choices that the description of the last editor is cut off. The resort is to show the description only of the selected editor, and to display the selection as a combobox instead of radio buttons. This concludes git-for-windows/git#1356 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Related to #291, the idea is to detect more editors and offer them as a choice. For example, VS Code can be detected by looking at
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\Code.exe\shell\open\command
which should be of the form"C:\Program Files\Microsoft VS Code\Code.exe" "%1"
. We can take the presence of that registry entry as a hint that VS Code is installed, and also how to start it: we simply need to copy the value, substitute the trailing"%1"
by--wait
and use the result as the value of the Git config optioncore.editor
.More choices for editors (and how to configure
core.editor
) are listed here: https://stackoverflow.com/questions/2596805/how-do-i-make-git-use-the-editor-of-my-choice-for-commitsAs the editor page is already pretty cramped, it would probably be a good idea to replace the radio buttons by a combobox.
This ticket is an excellent candidate for the Up For Grabs campaign.
So how to get started?
Install the Git for Windows SDK
When working on anything related to the Git for Windows installer, one needs a Git for Windows SDK. Currently, the easiest way to get one is to use the SDK installer.
This will download quite a bit of stuff, so you may want to grab a coffee or a tea or do something else entirely while this is running.
Once the SDK is done, you have a Git SDK Bash window, and also a Desktop shortcut to open the Git SDK Bash again. This will be the environment in which to work on the installer.
Test the Editor page of the installer
Pretty much all of the files, scripts and resources to build the installer are located in
/usr/src/build-extra/
, which corresponds to https://github.com/git-for-windows/build-extra, so go ahead and:cd /usr/src/build-extra
You could now build an installer by calling
./installer/release.sh 0-test
(which would generate a file calledGit-0-test-64-bit.exe
in your home directory), but that would take quite a while because it has to compress several hundred megabytes worth of files, and you would overwrite your current Git for Windows while testing it.Therefore, we introduced a convenient method to work on the installer pages without doing all that stuff:
will build a tiny installer that won't actually install anything but show you just the Editor "wizard page" of the installer.
Time to go hack on that page...
Add a new editor option
Most of the installer is defined in the file
installer/install.iss
. Most notably, this file contains the code to generate the pages and to handle the selected options: in the case of the Editor page, it has to configure thecore.editor
Git config setting.The code to generate the Editor page is located in the
InitializeWizard
procedure (InnoSetup, the system we use to generate our installers, uses a Pascal dialect as scripting language, where functions that do not have a return value are called procedures).No worries about the language, any developer with a little knowledge of Javascript, Python or C will be able to read the code and modify it by following the example of the surrounding code.
To add support for VS Code, you simply need to follow the example of Notepad++: just search for
NotepadPlusPlus
and copy-edit the respective code:core.editor
is set if VS Code was picked by the userOnce you did that, run
./installer/release.sh -d Editor
again, to see how it looks.Please note: whenever you run into any problem with all of this, do not hesitate to ask away in this ticket (describing the problem in enough detail to follow what you did).
Replace the radio buttons on the Editor page by a combo box
Now, it may just be the case that a nice description of VS Code will be too long, that it will be cut off at the bottom of the installer page. The obvious solution is to switch to a combo box for the editor options, and to show only one description at a time.
So how do we go about replacing the radio button by a combobox? The relevant command is
TNewComboBox.Create(Page)
. See e.g. https://stackoverflow.com/questions/31211733/inno-setup-combobox-how-to-store-access-values#31350903 for an example.As there is no previous code in our installer to add a combobox, we will have to replace the calls to
CreateRadioButton()
(which abstract away quite a bit of functionality) by new, more verbose code.To switch between descriptions, we would need to pull the code to generate a label (https://github.com/git-for-windows/build-extra/blob/c5a89e1f4928c2cf654ea426ce30d3e476001d7a/installer/install.iss#L923-L1039) out of the
CreateRadioButton()
function into its own function, say,CreateLabel()
. This new function would need to be called several times, once for each editor description, resetting theTop
variable after each call so that they would be all at the same location, setting theVisible
attribute of the label toFalse
so that none of them are shown at all, store all of theseTLabel
s in a new array, and add anOnChange
callback to show the current one (using theItemIndex
attribute of the combobox.Of course, after figuring out which one is the current one, we also have to set the
ItemIndex
of the combobox accordingly.The text was updated successfully, but these errors were encountered: