feature: external editor supports Sublime Text

This commit is contained in:
leo 2024-04-06 15:31:13 +08:00
parent d873f21b6a
commit 1196fabfc1
6 changed files with 101 additions and 4 deletions

View file

@ -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
}
}