Skip to content

Commit

Permalink
Small markdown rendering fixes (#610)
Browse files Browse the repository at this point in the history
* fixing bug causing crashes

* add conditional
  • Loading branch information
edkazcarlson-ms authored Nov 2, 2023
1 parent e15be89 commit b9002c9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
14 changes: 12 additions & 2 deletions src/Sarif.Viewer.VisualStudio.Core/ErrorList/ColumnFilterer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ private IWpfTableControl ErrorListTableControl
{
get
{
ThreadHelper.ThrowIfNotOnUIThread();
if (!SarifViewerPackage.IsUnitTesting)
{
#pragma warning disable VSTHRD108 // Assert thread affinity unconditionally
ThreadHelper.ThrowIfNotOnUIThread();
#pragma warning restore VSTHRD108
}

if (this.errorListTableControl == null)
{
Expand All @@ -42,7 +47,12 @@ private IWpfTableControl ErrorListTableControl

public void FilterOut(string columnName, string filteredValue)
{
ThreadHelper.ThrowIfNotOnUIThread();
if (!SarifViewerPackage.IsUnitTesting)
{
#pragma warning disable VSTHRD108 // Assert thread affinity unconditionally
ThreadHelper.ThrowIfNotOnUIThread();
#pragma warning restore VSTHRD108
}

var filteredColumnValue = new FilteredColumnValue(columnName, filteredValue);
if (!this.filteredColumnValues.Contains(filteredColumnValue))
Expand Down
10 changes: 9 additions & 1 deletion src/Sarif.Viewer.VisualStudio.Core/ResultTextMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,15 @@ internal bool TryToFullyPopulateRegionAndFilePath()
out resolvedUri)))
{
// Fill out the region's properties
this.fullyPopulatedRegion = FileRegionsCache.Instance.PopulateTextRegionProperties(this.region, resolvedUri, populateSnippet: true);
try
{
this.fullyPopulatedRegion = FileRegionsCache.Instance.PopulateTextRegionProperties(this.region, resolvedUri, populateSnippet: true);
}
catch (ArgumentOutOfRangeException)
{
// in the case there is a mismatch between the file opened on the users device and the file used to create the insight, this can throw an error due to one being larger than the other.
return false;
}
}
}

Expand Down
13 changes: 10 additions & 3 deletions src/Sarif.Viewer.VisualStudio.Core/Tags/SarifLocationErrorTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,17 @@ private void ApplyStylingRecurs(Block parentBlock, object obj, Brush textBrush,
/// <param name="e">The event of being clicked.</param>
private void Block_MouseDown(object sender, MouseButtonEventArgs e)
{
if (sender is Hyperlink hyperlink)
try
{
Process.Start(new ProcessStartInfo(hyperlink.NavigateUri.AbsoluteUri));
e.Handled = true;
if (sender is Hyperlink hyperlink)
{
Process.Start(new ProcessStartInfo(hyperlink.NavigateUri.AbsoluteUri));
e.Handled = true;
}
}
catch (Exception)
{
// in case that we cannot navigate to the uri for whatever reason we want to swallow as we do not want to crash VS as a whole.
}
}

Expand Down

0 comments on commit b9002c9

Please sign in to comment.