Skip to content

Commit

Permalink
Apply highlight options changes
Browse files Browse the repository at this point in the history
Commit 3f4aeb0 switched from MainPackage.GeneralOptions to .HighlightOptions, but I missed two places where the .GeneralOptions.Applied event was used. That meant changing .HighlightOptions properties wouldn't cause text to be reclassified (i.e., re-highlighted) without a restart.

Also, added default gray highlight rule for "CPM preview" message that's discussed at NuGet/Home#11724. This way the annoying preview message is rendered as gray text rather than normal text.
  • Loading branch information
menees committed Jun 15, 2022
1 parent 6baa77b commit 15cef53
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/Menees.VsTools/Editor/ClassifierBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ protected ClassifierBase(ITextBuffer buffer)
this.buffer = buffer;
buffer.ContentTypeChanged += this.TextBuffer_ContentTypeChanged;

// Indicate that we need to re-classify everything when our VSTools options change (specifically the highlighting options).
MainPackage.GeneralOptions.Applied += this.PackageOptionsApplied;
// Indicate that we need to re-classify everything when our VSTools highlighting options change.
MainPackage.HighlightOptions.Applied += this.HighlightOptionsApplied;
}

#endregion
Expand Down Expand Up @@ -100,7 +100,7 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
this.buffer.ContentTypeChanged -= this.TextBuffer_ContentTypeChanged;
MainPackage.GeneralOptions.Applied -= this.PackageOptionsApplied;
MainPackage.HighlightOptions.Applied -= this.HighlightOptionsApplied;
}
}

Expand Down Expand Up @@ -141,10 +141,10 @@ private void TextBuffer_ContentTypeChanged(object sender, ContentTypeChangedEven
this.ContentTypeChanged(this.buffer, e);
}

private void PackageOptionsApplied(object sender, EventArgs e)
private void HighlightOptionsApplied(object sender, EventArgs e)
{
// If any of the Menees VS Tools options change, we'll re-classify. Typically, only a few options actually
// affect each classifier, but it's rare for any of the package options to change. So it doesn't hurt to just
// If any of the Menees VS Tools highlighting options change, we'll re-classify. Typically, only a few options actually
// affect each classifier, but it's rare for any of the highlighting options to change. So it doesn't hurt to just
// re-classify if anything changed.
this.OptionsChanged(null);
}
Expand Down
7 changes: 7 additions & 0 deletions src/Menees.VsTools/Editor/HighlightOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ private static List<OutputHighlight> CreateDefaultOutputHighlights()
if (buildContent.Length > 0)
{
result.Add(new OutputHighlight("Code Analysis Success", OutputHighlightType.None, @"\s0 error\(s\), 0 warning\(s\)$", buildContent));

// This default can go away once https://github.com/NuGet/Home/issues/11724 and https://github.com/NuGet/Home/issues/11752 ship.
result.Add(new OutputHighlight(
"CentralPackageVersionManagement Preview",
OutputHighlightType.Detail,
@"using CentralPackageVersionManagement, a NuGet preview feature",
buildContent));
}

// The "Ext: ExceptionBreaker (Diagnostic)" pane uses a general Output content type.
Expand Down
2 changes: 1 addition & 1 deletion src/Menees.VsTools/MainPackage.Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed partial class MainPackage
//
// Note: When the version changes (major, minor, build, or revision), also update:
// - source.extension.vsixmanifest: <Identity Version="*"/>
internal const string Version = VersionYear + ".0.3";
internal const string Version = VersionYear + ".0.4";

internal const string Title = "Menees VS Tools";

Expand Down
2 changes: 1 addition & 1 deletion src/Menees.VsTools/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="Menees VS Tools 2022" Version="2022.0.3" Language="en-US" Publisher="Bill Menees" />
<Identity Id="Menees VS Tools 2022" Version="2022.0.4" Language="en-US" Publisher="Bill Menees" />
<DisplayName>Menees VS Tools 2022</DisplayName>
<Description xml:space="preserve">Provides several new commands such as Sort Lines, Sort Members, Trim, Statistics, ExecuteFile, AddRegion, CollapseAllRegions, ExpandAllRegions, and ToggleFiles.

Expand Down

0 comments on commit 15cef53

Please sign in to comment.