Change the way to preview binary in CommitViewer

This commit is contained in:
leo 2020-07-13 20:41:17 +08:00
parent 261b4d635c
commit 689b02cd61
3 changed files with 34 additions and 17 deletions

View file

@ -345,13 +345,20 @@ namespace SourceGit.UI {
private async void FileTreeItemSelected(object sender, RoutedPropertyChangedEventArgs<object> e) {
filePreview.Text = "";
maskPreviewNotSupported.Visibility = Visibility.Collapsed;
var node = e.NewValue as Node;
if (node == null || !node.IsFile) return;
await Task.Run(() => {
var data = commit.GetTextFileContent(repo, node.FilePath);
Dispatcher.Invoke(() => filePreview.Text = data);
var isBinary = false;
var data = commit.GetTextFileContent(repo, node.FilePath, out isBinary);
if (isBinary) {
Dispatcher.Invoke(() => maskPreviewNotSupported.Visibility = Visibility.Visible);
} else {
Dispatcher.Invoke(() => filePreview.Text = data);
}
});
}
#endregion