diff --git a/README.md b/README.md index 99928589..351fecb0 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ This app supports open repository in external editors listed in the table below. | Visual Studio Code | YES | YES | YES | VSCODE_PATH | | Visual Studio Code - Insiders | YES | YES | YES | VSCODE_INSIDERS_PATH | | JetBrains Fleet | YES | YES | YES | FLEET_PATH | +| Sublime Text | YES | YES | YES | SUBLIME_TEXT_PATH | You can set the given environment variable for special editor if it can NOT be found by this app automatically. diff --git a/src/Models/ExternalMergeTools.cs b/src/Models/ExternalMergeTools.cs index 4baab460..f07ef088 100644 --- a/src/Models/ExternalMergeTools.cs +++ b/src/Models/ExternalMergeTools.cs @@ -22,10 +22,10 @@ namespace SourceGit.Models new ExternalMergeTools(0, "Custom", "", "", ""), new ExternalMergeTools(1, "Visual Studio Code", "Code.exe", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""), new ExternalMergeTools(2, "Visual Studio Code - Insiders", "Code - Insiders.exe", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""), - new ExternalMergeTools(3, "Visual Studio 2017/2019", "vsDiffMerge.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" /m", "\"$LOCAL\" \"$REMOTE\""), + new ExternalMergeTools(3, "Visual Studio 2017/2019/2022", "vsDiffMerge.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" /m", "\"$LOCAL\" \"$REMOTE\""), new ExternalMergeTools(4, "Tortoise Merge", "TortoiseMerge.exe;TortoiseGitMerge.exe", "-base:\"$BASE\" -theirs:\"$REMOTE\" -mine:\"$LOCAL\" -merged:\"$MERGED\"", "-base:\"$LOCAL\" -theirs:\"$REMOTE\""), new ExternalMergeTools(5, "KDiff3", "kdiff3.exe", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""), - new ExternalMergeTools(6, "Beyond Compare 4", "BComp.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""), + new ExternalMergeTools(6, "Beyond Compare", "BComp.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""), new ExternalMergeTools(7, "WinMerge", "WinMergeU.exe", "-u -e \"$REMOTE\" \"$LOCAL\" \"$MERGED\"", "-u -e \"$LOCAL\" \"$REMOTE\""), }; } @@ -37,7 +37,7 @@ namespace SourceGit.Models new ExternalMergeTools(2, "Visual Studio Code", "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""), new ExternalMergeTools(3, "Visual Studio Code - Insiders", "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""), new ExternalMergeTools(4, "KDiff3", "/Applications/kdiff3.app/Contents/MacOS/kdiff3", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""), - new ExternalMergeTools(5, "Beyond Compare 4", "/Applications/Beyond Compare.app/Contents/MacOS/bcomp", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""), + new ExternalMergeTools(5, "Beyond Compare", "/Applications/Beyond Compare.app/Contents/MacOS/bcomp", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""), }; } else if (OperatingSystem.IsLinux()) @@ -47,7 +47,7 @@ namespace SourceGit.Models new ExternalMergeTools(1, "Visual Studio Code", "/usr/share/code/code", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""), new ExternalMergeTools(2, "Visual Studio Code - Insiders", "/usr/share/code-insiders/code-insiders", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""), new ExternalMergeTools(3, "KDiff3", "/usr/bin/kdiff3", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""), - new ExternalMergeTools(4, "Beyond Compare 4", "/usr/bin/bcomp", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""), + new ExternalMergeTools(4, "Beyond Compare", "/usr/bin/bcomp", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""), }; } else diff --git a/src/Native/Linux.cs b/src/Native/Linux.cs index dd31e0c8..b56ac31a 100644 --- a/src/Native/Linux.cs +++ b/src/Native/Linux.cs @@ -71,6 +71,18 @@ namespace SourceGit.Native }); } + var sublime = FindSublimeText(); + if (!string.IsNullOrEmpty(sublime) && File.Exists(sublime)) + { + editors.Add(new Models.ExternalEditor + { + Name = "Sublime Text", + Icon = "sublime_text.png", + Executable = sublime, + OpenCmdArgs = "\"{0}\"", + }); + } + return editors; } @@ -187,6 +199,25 @@ namespace SourceGit.Native return string.Empty; } + + private string FindSublimeText() + { + if (File.Exists("/usr/bin/subl")) + { + return "/usr/bin/subl"; + } + + if (File.Exists("/usr/local/bin/subl")) + { + return "/usr/local/bin/subl"; + } + + var customPath = Environment.GetEnvironmentVariable("SUBLIME_TEXT_PATH"); + if (!string.IsNullOrEmpty(customPath)) + return customPath; + + return string.Empty; + } #endregion } } diff --git a/src/Native/MacOS.cs b/src/Native/MacOS.cs index ab9bc992..a695b7dc 100644 --- a/src/Native/MacOS.cs +++ b/src/Native/MacOS.cs @@ -68,6 +68,18 @@ namespace SourceGit.Native }); } + var sublime = FindSublimeText(); + if (!string.IsNullOrEmpty(sublime) && File.Exists(sublime)) + { + editors.Add(new Models.ExternalEditor + { + Name = "Sublime Text", + Icon = "sublime_text.png", + Executable = sublime, + OpenCmdArgs = "\"{0}\"", + }); + } + return editors; } @@ -150,6 +162,20 @@ namespace SourceGit.Native return string.Empty; } + + private string FindSublimeText() + { + if (File.Exists("/Applications/Sublime Text.app/Contents/SharedSupport/bin")) + { + return "/Applications/Sublime Text.app/Contents/SharedSupport/bin"; + } + + var customPath = Environment.GetEnvironmentVariable("SUBLIME_TEXT_PATH"); + if (!string.IsNullOrEmpty(customPath)) + return customPath; + + return string.Empty; + } #endregion } } diff --git a/src/Native/Windows.cs b/src/Native/Windows.cs index f91a6da5..e7ef0fd8 100644 --- a/src/Native/Windows.cs +++ b/src/Native/Windows.cs @@ -154,6 +154,18 @@ namespace SourceGit.Native }); } + var sublime = FindSublimeText(); + if (!string.IsNullOrEmpty(sublime) && File.Exists(sublime)) + { + editors.Add(new Models.ExternalEditor + { + Name = "Sublime Text", + Icon = "sublime_text.png", + Executable = sublime, + OpenCmdArgs = "\"{0}\"", + }); + } + return editors; } @@ -303,6 +315,33 @@ namespace SourceGit.Native return string.Empty; } + + private string FindSublimeText() + { + var localMachine = Microsoft.Win32.RegistryKey.OpenBaseKey( + Microsoft.Win32.RegistryHive.LocalMachine, + Microsoft.Win32.RegistryView.Registry64); + + var sublime = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sublime Text_is1"); + if (sublime != null) + { + var icon = sublime.GetValue("DisplayIcon") as string; + return Path.Combine(Path.GetDirectoryName(icon), "subl.exe"); + } + + var sublime3 = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sublime Text 3_is1"); + if (sublime3 != null) + { + var icon = sublime3.GetValue("DisplayIcon") as string; + return Path.Combine(Path.GetDirectoryName(icon), "subl.exe"); + } + + var customPath = Environment.GetEnvironmentVariable("SUBLIME_TEXT_PATH"); + if (!string.IsNullOrEmpty(customPath)) + return customPath; + + return string.Empty; + } #endregion private void OpenFolderAndSelectFile(string folderPath) diff --git a/src/Resources/ExternalToolIcons/sublime_text.png b/src/Resources/ExternalToolIcons/sublime_text.png new file mode 100644 index 00000000..2296cecb Binary files /dev/null and b/src/Resources/ExternalToolIcons/sublime_text.png differ