Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Fix unhandled exception if code coverage results file does not exist.
Browse files Browse the repository at this point in the history
Show error message in code coverage pad's text editor if the code coverage file does not exist.
  • Loading branch information
mrward committed Oct 14, 2012
1 parent fe5802b commit 28d9289
Showing 1 changed file with 14 additions and 1 deletion.
Expand Up @@ -318,7 +318,9 @@ void ListViewItemActivate(object sender, EventArgs e)
void OpenFile(string fileName, int line, int column)
{
if (fileName != textEditorFileName) {
textEditor.Load(fileName);
if (!TryLoadFileIntoTextEditor(fileName)) {
return;
}
textEditor.SyntaxHighlighting = GetSyntaxHighlighting(fileName);
}
textEditor.ScrollToEnd();
Expand All @@ -327,6 +329,17 @@ void OpenFile(string fileName, int line, int column)
CodeCoverageService.ShowCodeCoverage(new AvalonEditTextEditorAdapter(textEditor), fileName);
}

bool TryLoadFileIntoTextEditor(string fileName)
{
if (!File.Exists(fileName)) {
textEditor.Text = String.Format("File does not exist '{0}'.", fileName);
return false;
}

textEditor.Load(fileName);
return true;
}

IHighlightingDefinition GetSyntaxHighlighting(string fileName)
{
return HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(fileName));
Expand Down

0 comments on commit 28d9289

Please sign in to comment.