mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
refactor: open selected revision file (#681)
Some checks are pending
Some checks are pending
* Instead of opening the file from current worktree, save the selected revision file to the temp dir and the open it with default editor * Do NOT set the `IsEnable` property, since the revision file is always available Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
db66ba82a6
commit
503f700fc2
1 changed files with 5 additions and 2 deletions
|
@ -381,10 +381,13 @@ namespace SourceGit.ViewModels
|
||||||
var openWith = new MenuItem();
|
var openWith = new MenuItem();
|
||||||
openWith.Header = App.Text("OpenWith");
|
openWith.Header = App.Text("OpenWith");
|
||||||
openWith.Icon = App.CreateMenuIcon("Icons.OpenWith");
|
openWith.Icon = App.CreateMenuIcon("Icons.OpenWith");
|
||||||
openWith.IsEnabled = File.Exists(fullPath);
|
|
||||||
openWith.Click += (_, ev) =>
|
openWith.Click += (_, ev) =>
|
||||||
{
|
{
|
||||||
Native.OS.OpenWithDefaultEditor(fullPath);
|
var fileName = Path.GetFileNameWithoutExtension(fullPath) ?? "";
|
||||||
|
var fileExt = Path.GetExtension(fullPath) ?? "";
|
||||||
|
var tmpFile = Path.Combine(Path.GetTempPath(), $"{fileName}~{_commit.SHA.Substring(0, 10)}{fileExt}");
|
||||||
|
Commands.SaveRevisionFile.Run(_repo.FullPath, _commit.SHA, file.Path, tmpFile);
|
||||||
|
Native.OS.OpenWithDefaultEditor(tmpFile);
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue