Skip to content

Commit

Permalink
Merge pull request #5838 from mstv/feature/f3_opens_difftool_for_png
Browse files Browse the repository at this point in the history
Implement F3 to open difftool for .png
  • Loading branch information
RussKie committed Dec 21, 2018
2 parents ef1b946 + 00de6d3 commit e5878bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions GitUI/CommandsDialogs/FormCommit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,13 +1112,14 @@ private void ShowChanges(GitItemStatus item, bool staged)

private async Task SetSelectedDiffAsync(GitItemStatus item, bool staged)
{
Action openWithDiffTool = () => (staged ? stagedOpenDifftoolToolStripMenuItem9 : openWithDifftoolToolStripMenuItem).PerformClick();
if (item.Name.EndsWith(".png"))
{
await SelectedDiff.ViewFileAsync(item.Name);
await SelectedDiff.ViewFileAsync(item.Name, openWithDiffTool);
}
else if (item.IsTracked)
{
SelectedDiff.ViewCurrentChanges(item, staged, () => (staged ? stagedOpenDifftoolToolStripMenuItem9 : openWithDifftoolToolStripMenuItem).PerformClick());
SelectedDiff.ViewCurrentChanges(item, staged, openWithDiffTool);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions GitUI/Editor/FileViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public ArgumentString GetExtraDiffArguments()
};
}

public Task ViewFileAsync(string fileName)
public Task ViewFileAsync(string fileName, [CanBeNull] Action openWithDifftool = null)
{
return ShowOrDeferAsync(
fileName,
Expand All @@ -352,7 +352,7 @@ public Task ViewFileAsync(string fileName)
getImage: GetImage,
getFileText: GetFileText,
getSubmoduleText: () => LocalizationHelpers.GetSubmoduleText(Module, fileName.TrimEnd('/'), ""),
openWithDifftool: null /* not implemented */));
openWithDifftool));

Image GetImage()
{
Expand Down Expand Up @@ -770,7 +770,7 @@ private Task ViewItemAsync(string fileName, Func<Image> getImage, Func<string> g
}
PictureBox.Image = image == null ? null : DpiUtil.Scale(image);
internalFileViewer.SetText("", () => { });
internalFileViewer.SetText("", openWithDifftool);
});
}

Expand Down

0 comments on commit e5878bc

Please sign in to comment.