Skip to content

Commit

Permalink
WIP: Use TaskDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
bansan85 committed Mar 29, 2023
1 parent 72df9c3 commit 5b8d2dc
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions GitUI/Editor/FileViewer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO.Pipes;
using System.Text;
using System.Text.RegularExpressions;
using GitCommands;
Expand Down Expand Up @@ -1636,26 +1637,24 @@ private void ProcessApplyOutput(GitArgumentBuilder args, byte[] patch, bool patc

if (!result.ExitedSuccessfully && (patchUpdateDiff || !MergeConflictHandler.HandleMergeConflicts(UICommands, this, false, false)))
{
const int max_lines = 20;
int count = 0;
string truncated_output = Encoding.GetString(patch).LazySplit('\n').Take(max_lines + 1).Select(x =>
TaskDialogPage page = new()
{
count++;
if (count > max_lines)
{
return "";
}
return x;
}).Join("\n");
Heading = "Failed to apply patch",
Text = output,
Icon = TaskDialogIcon.Error,
Buttons = { TaskDialogButton.OK },
AllowCancel = true
};

if (count > max_lines)
page.Expander = new TaskDialogExpander
{
truncated_output += "...\n\nOutput truncated.";
}
CollapsedButtonText = TranslatedStrings.GitDubiousOwnershipSeeGitCommandOutput,
ExpandedButtonText = TranslatedStrings.GitDubiousOwnershipHideGitCommandOutput,
Position = TaskDialogExpanderPosition.AfterFootnote,
Text = Encoding.GetString(patch),
};

MessageBox.Show(this, $"{output}\n\n{truncated_output}", TranslatedStrings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
TaskDialog.ShowDialog(page);
}
else if (!result.ExitedSuccessfully || output.StartsWith("error: ") || output.StartsWith("warning: "))
{
Expand Down

0 comments on commit 5b8d2dc

Please sign in to comment.