Skip to content

Commit

Permalink
installer: detect (and prefer) system-wide Sublime Text installation
Browse files Browse the repository at this point in the history
We support the Sublime Text editor for a while now, but only the
user-wide installation.

This developer was not even able to install Sublime Text in that way,
only the regular system-wide installation.

Sadly, there is no registry entry that we can detect, but the default
location is easy enough to figure out, and we can use it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Feb 26, 2019
1 parent 36a5e92 commit 396b283
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions installer/install.iss
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ var
VisualStudioCodeUserInstallation:Boolean;
VisualStudioCodeInsidersUserInstallation:Boolean;
SublimeTextUserInstallation:Boolean;
NotepadPlusPlusPath:String;
VisualStudioCodePath:String;
Expand Down Expand Up @@ -1503,7 +1504,12 @@ begin
EditorAvailable[GE_VisualStudioCodeInsiders]:=RegQueryStringValue(HKEY_CURRENT_USER,'Software\Classes\Applications\Code - Insiders.exe\shell\open\command','',VisualStudioCodeInsidersPath);
VisualStudioCodeInsidersUserInstallation:=True;
end;
EditorAvailable[GE_SublimeText]:=RegQueryStringValue(HKEY_CURRENT_USER,'Software\Classes\Applications\sublime_text.exe\shell\open\command','',SublimeTextPath);
SublimeTextPath:=ExpandConstant('{pf}\Sublime Text 3\subl.exe');
EditorAvailable[GE_SublimeText]:=PathIsValidExecutable(SublimeTextPath);
if (not EditorAvailable[GE_SublimeText]) then begin
EditorAvailable[GE_SublimeText]:=RegQueryStringValue(HKEY_CURRENT_USER,'Software\Classes\Applications\sublime_text.exe\shell\open\command','',SublimeTextPath);
SublimeTextUserInstallation:=True;
end;
EditorAvailable[GE_Atom]:=RegQueryStringValue(HKEY_CURRENT_USER,'Software\Classes\Applications\atom.exe\shell\open\command','',AtomPath);
EditorAvailable[GE_CustomEditor]:=True;
Expand All @@ -1514,7 +1520,7 @@ begin
if (EditorAvailable[GE_VisualStudioCodeInsiders]) then
// Extract <path> from "<path>" "%1"
VisualStudioCodeInsidersPath:=Copy(VisualStudioCodeInsidersPath, 2, Length(VisualStudioCodeInsidersPath) - 7);
if (EditorAvailable[GE_SublimeText]) then
if (EditorAvailable[GE_SublimeText]) and SublimeTextUserInstallation then
// Extract <path> from "<path>" "%1"
SublimeTextPath:=Copy(SublimeTextPath, 2, Length(SublimeTextPath) - 7);
if (EditorAvailable[GE_Atom]) then
Expand Down Expand Up @@ -1560,7 +1566,10 @@ begin
// 6th choice
Top:=TopOfLabels;
CbbEditor.Items.Add('Use Sublime Text as Git'+#39+'s default editor');
CreateItemDescription(EditorPage,'<RED>(NEW!)</RED> <A HREF=https://www.sublimetext.com/>Sublime text</A> is a lightweight editor which supports a great number'+#13+'of plugins.'+#13+'<RED>(WARNING!) This will be installed only for this user.</RED>'+#13+#13+'Use this option to let Git use Sublime Text as its default editor.',Top,Left,LblEditor[GE_SublimeText],False);
if (SublimeTextUserInstallation=False) then
CreateItemDescription(EditorPage,'<RED>(NEW!)</RED> <A HREF=https://www.sublimetext.com/>Sublime text</A> is a lightweight editor which supports a great number'+#13+'of plugins.'+#13+#13+'Use this option to let Git use Sublime Text as its default editor.',Top,Left,LblEditor[GE_SublimeText],False)
else
CreateItemDescription(EditorPage,'<RED>(NEW!)</RED> <A HREF=https://www.sublimetext.com/>Sublime text</A> is a lightweight editor which supports a great number'+#13+'of plugins.'+#13+'<RED>(WARNING!) This will be installed only for this user.</RED>'+#13+#13+'Use this option to let Git use Sublime Text as its default editor.',Top,Left,LblEditor[GE_SublimeText],False);
// 7th choice
Top:=TopOfLabels;
Expand Down Expand Up @@ -2632,7 +2641,9 @@ begin
LogError('Could not set Visual Studio Code Insiders as core.editor in the gitconfig.')
end
end else if ((CbbEditor.ItemIndex=GE_SublimeText)) and (SublimeTextPath<>'') then begin
if not ExecAsOriginalUser(AppDir + '\{#MINGW_BITNESS}\bin\git.exe','config --global core.editor "\"'+SublimeTextPath+'\" -w"','',SW_HIDE,ewWaitUntilTerminated, i) then
if (SublimeTextUserInstallation=False) then
GitSystemConfigSet('core.editor','"'+SublimeTextPath+'" -w')
else if not ExecAsOriginalUser(AppDir + '\{#MINGW_BITNESS}\bin\git.exe','config --global core.editor "\"'+SublimeTextPath+'\" -w"','',SW_HIDE,ewWaitUntilTerminated, i) then
LogError('Could not set Sublime Text as core.editor in the gitconfig.');
end else if ((CbbEditor.ItemIndex=GE_Atom)) and (AtomPath<>'') then begin
if not ExecAsOriginalUser(AppDir + '\{#MINGW_BITNESS}\bin\git.exe','config --global core.editor "\"'+AtomPath+'\" --wait"','',SW_HIDE,ewWaitUntilTerminated, i) then
Expand Down

0 comments on commit 396b283

Please sign in to comment.