Skip to content

Commit

Permalink
! Showed comment tagger on all supported document types
Browse files Browse the repository at this point in the history
  • Loading branch information
wmjordan committed Dec 9, 2018
1 parent 09d5bf0 commit 2f9f0c4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Codist/Classifiers/CommentTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ public ITagger<T> CreateTagger<T>(ITextView textView, ITextBuffer buffer) where
return codeTagger as ITagger<T>;
}

internal static bool IsCommentTaggable(ITextView view) {
return GetCodeType(view.TextBuffer.ContentType) != CodeType.None;
}
static CodeType GetCodeType(IContentType contentType) {
return contentType.IsOfType(Constants.CodeTypes.CSharp) ? CodeType.CSharp
: contentType.IsOfType("html") || contentType.IsOfType("htmlx") || contentType.IsOfType("XAML") || contentType.IsOfType("XML") ? CodeType.Markup
: contentType.IsOfType("code++.css") ? CodeType.Css
: contentType.IsOfType("TypeScript") ? CodeType.Js
: contentType.IsOfType("TypeScript") || contentType.IsOfType("JavaScript") ? CodeType.Js
: contentType.IsOfType("C/C++") ? CodeType.C
: CodeType.None;
}
Expand Down
6 changes: 4 additions & 2 deletions Codist/Margins/CommentMarginFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Codist.Margins
[Name(CommentMargin.MarginName)]
[Order(After = PredefinedMarginNames.OverviewChangeTracking, Before = PredefinedMarginNames.OverviewMark)]
[MarginContainer(PredefinedMarginNames.VerticalScrollBar)]
[ContentType(Constants.CodeTypes.CSharp)]
[ContentType(Constants.CodeTypes.Code)]
[TextViewRole(PredefinedTextViewRoles.Interactive)]
sealed class CommentMarginFactory : IWpfTextViewMarginProvider
{
Expand All @@ -28,7 +28,9 @@ sealed class CommentMarginFactory : IWpfTextViewMarginProvider
/// </returns>
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) {
var scrollBarContainer = marginContainer as IVerticalScrollBar;
return Config.Instance.Features.MatchFlags(Features.ScrollbarMarkers) && scrollBarContainer != null
return Config.Instance.Features.MatchFlags(Features.ScrollbarMarkers)
&& scrollBarContainer != null
&& Classifiers.CommentTaggerProvider.IsCommentTaggable(wpfTextViewHost.TextView)
? new CommentMargin(wpfTextViewHost.TextView, scrollBarContainer)
: null;
}
Expand Down
2 changes: 0 additions & 2 deletions Codist/Margins/LineNumberMargin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ sealed class LineNumberMargin : FrameworkElement, IDisposable, IWpfTextViewMargi
readonly IWpfTextView _TextView;
readonly IEditorFormatMap _EditorFormatMap;
readonly IVerticalScrollBar _ScrollBar;
readonly TaggerResult _Tags;

static readonly SolidColorBrush LineNumberBrush = Brushes.DarkGray;
static readonly Pen LineNumberPen = new Pen(LineNumberBrush, 1) { DashStyle = DashStyles.Dash };
Expand All @@ -29,7 +28,6 @@ public LineNumberMargin(IWpfTextView textView, IVerticalScrollBar scrollBar) {
IsHitTestVisible = false;

_ScrollBar = scrollBar;
_Tags = textView.Properties.GetOrCreateSingletonProperty(() => new TaggerResult());
_EditorFormatMap = ServicesHelper.Instance.EditorFormatMap.GetEditorFormatMap(textView);

Width = 0;
Expand Down

0 comments on commit 2f9f0c4

Please sign in to comment.