Skip to content

Commit 503f700

Browse files
committed
refactor: open selected revision file (#681)
* 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 <[email protected]>
1 parent db66ba8 commit 503f700

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ViewModels/CommitDetail.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,13 @@ public ContextMenu CreateRevisionFileContextMenu(Models.Object file)
381381
var openWith = new MenuItem();
382382
openWith.Header = App.Text("OpenWith");
383383
openWith.Icon = App.CreateMenuIcon("Icons.OpenWith");
384-
openWith.IsEnabled = File.Exists(fullPath);
385384
openWith.Click += (_, ev) =>
386385
{
387-
Native.OS.OpenWithDefaultEditor(fullPath);
386+
var fileName = Path.GetFileNameWithoutExtension(fullPath) ?? "";
387+
var fileExt = Path.GetExtension(fullPath) ?? "";
388+
var tmpFile = Path.Combine(Path.GetTempPath(), $"{fileName}~{_commit.SHA.Substring(0, 10)}{fileExt}");
389+
Commands.SaveRevisionFile.Run(_repo.FullPath, _commit.SHA, file.Path, tmpFile);
390+
Native.OS.OpenWithDefaultEditor(tmpFile);
388391
ev.Handled = true;
389392
};
390393

0 commit comments

Comments
 (0)