refactor: open selected revision file (#681)
Some checks are pending
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions
Localization Check / localization-check (push) Waiting to run

* 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:
leo 2024-11-11 20:24:17 +08:00
parent db66ba82a6
commit 503f700fc2
No known key found for this signature in database

View file

@ -381,10 +381,13 @@ namespace SourceGit.ViewModels
var openWith = new MenuItem();
openWith.Header = App.Text("OpenWith");
openWith.Icon = App.CreateMenuIcon("Icons.OpenWith");
openWith.IsEnabled = File.Exists(fullPath);
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;
};