Skip to content

Commit

Permalink
Merge pull request #104 from lordfanger/html-editor
Browse files Browse the repository at this point in the history
Support for another HTML editor
[release]
  • Loading branch information
madskristensen authored Aug 16, 2023
2 parents dec5b74 + 4448d12 commit d72df3e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Tagger/RainbowTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ private static AllowanceResolver GetAllowanceResolver(ITextBuffer buffer)
"LEGACYRAZORVISUALBASIC" => new RazorAllowanceResolver(),
"WEBFORMS" => new RazorAllowanceResolver(),
"LEGACYRAZORCSHARP" => new RazorAllowanceResolver(),
"HTML-DELEGATION" => new RazorAllowanceResolver(),
_ => new DefaultAllowanceResolver()
};

Expand Down
3 changes: 3 additions & 0 deletions src/Tagger/RainbowTaggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace RainbowBraces
[ContentType("Razor")]
[ContentType("LegacyRazorVisualBasic")]
[ContentType("WebForms")]
[ContentType("html-delegation")]
[TextViewRole(PredefinedTextViewRoles.PrimaryDocument)]
[TextViewRole(PredefinedTextViewRoles.EmbeddedPeekTextView)]
[TextViewRole(CustomTextViewRoles.StickyScroll)]
Expand Down Expand Up @@ -91,6 +92,7 @@ static bool IsSuportedHtmlTextBufferContentType(IContentType contentType)
{
if (contentType.IsOfType("HTMLProjection")) return true;
if (contentType.IsOfType("WebFormsProjection")) return true;
if (contentType.IsOfType("html-delegation")) return true;
return false;
}

Expand All @@ -101,6 +103,7 @@ static bool IsSupportedHtmlContentType(IContentType contentType)
if (contentType.IsOfType("CSharp")) return true;
if (contentType.IsOfType("WebForms")) return true;
if (contentType.IsOfType("LegacyRazorCSharp")) return true;
if (contentType.IsOfType("html-delegation")) return true;
return false;
}
}
Expand Down
16 changes: 12 additions & 4 deletions src/Tagger/RazorAllowanceResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ public class RazorAllowanceResolver : DefaultAllowanceResolver
protected override TagAllowance IsAllowed(IClassificationType tagType)
{
// string (eg. interpolated or parameter filling) tag can contain punctuation or inlined C# code and braces without tags are ignored by default (DefaultAllowed = false)
if (tagType.IsOfType(PredefinedClassificationTypeNames.String)) return TagAllowance.Ignore;

if (General.Instance.XmlTags && tagType.IsOfType("HTML Tag Delimiter")) return TagAllowance.XmlTag;
if (tagType.IsOfType(PredefinedClassificationTypeNames.String)) return TagAllowance.Ignore;

if (General.Instance.XmlTags)
{
if (tagType.IsOfType("HTML Tag Delimiter")) return TagAllowance.XmlTag;
if (tagType.IsOfType("HTML Operator")) return TagAllowance.XmlTag;
}

return base.IsAllowed(tagType);
}
Expand All @@ -42,7 +46,11 @@ protected override TagAllowance IsAllowed(ILayeredClassificationType layeredType
// string (eg. interpolated or parameter filling) tag can contain punctuation or inlined C# code and braces without tags are ignored by default (DefaultAllowed = false)
if (classification == PredefinedClassificationTypeNames.String) return TagAllowance.Ignore;

if (General.Instance.XmlTags && layeredType.Classification is "HTML Tag Delimiter") return TagAllowance.XmlTag;
if (General.Instance.XmlTags)
{
if (layeredType.Classification is "HTML Tag Delimiter") return TagAllowance.XmlTag;
if (layeredType.Classification is "HTML Operator") return TagAllowance.XmlTag;
}

return base.IsAllowed(layeredType);
}
Expand Down

0 comments on commit d72df3e

Please sign in to comment.