diff --git a/Debugger/ILSpy.Debugger/AvalonEdit/ITextMarker.cs b/Debugger/ILSpy.Debugger/AvalonEdit/ITextMarker.cs index 9b4743545..90358b123 100644 --- a/Debugger/ILSpy.Debugger/AvalonEdit/ITextMarker.cs +++ b/Debugger/ILSpy.Debugger/AvalonEdit/ITextMarker.cs @@ -5,6 +5,8 @@ using System; using System.Collections.Generic; using System.Windows.Media; +using ILSpy.Debugger.Bookmarks; + namespace ILSpy.Debugger.AvalonEdit { /// @@ -71,6 +73,16 @@ namespace ILSpy.Debugger.AvalonEdit /// Gets/Sets an object that will be displayed as tooltip in the text editor. /// object ToolTip { get; set; } + + /// + /// Gets or sets if the marker is visible or not. + /// + Predicate IsVisible { get; set; } + + /// + /// Gets or sets the bookmark. + /// + IBookmark Bookmark { get; set; } } public enum TextMarkerType diff --git a/Debugger/ILSpy.Debugger/AvalonEdit/TextMarkerService.cs b/Debugger/ILSpy.Debugger/AvalonEdit/TextMarkerService.cs index 2e7191f32..2eea45416 100644 --- a/Debugger/ILSpy.Debugger/AvalonEdit/TextMarkerService.cs +++ b/Debugger/ILSpy.Debugger/AvalonEdit/TextMarkerService.cs @@ -49,10 +49,10 @@ namespace ILSpy.Debugger.AvalonEdit { if (e.Bookmark is MarkerBookmark) { var bm = (MarkerBookmark)e.Bookmark; - if (DebugData.CurrentType != null && DebugData.CurrentType.FullName.Equals(bm.Type.FullName, StringComparison.OrdinalIgnoreCase)) { + if (DebugData.CurrentType != null && DebugData.CurrentType == bm.Type) { // add bookmark for the current type DocumentLine line = codeEditor.Document.GetLineByNumber(bm.LineNumber); - bm.Marker = bm.CreateMarker(this, line.Offset, line.Length); + bm.CreateMarker(this, line.Offset, line.Length); } } } @@ -120,6 +120,9 @@ namespace ILSpy.Debugger.AvalonEdit int lineStart = line.Offset; int lineEnd = lineStart + line.Length; foreach (TextMarker marker in markers.FindOverlappingSegments(lineStart, line.Length).Reverse()) { + if (!marker.IsVisible(marker.Bookmark)) + continue; + Brush foregroundBrush = null; if (marker.ForegroundColor != null) { foregroundBrush = new SolidColorBrush(marker.ForegroundColor.Value); @@ -160,6 +163,9 @@ namespace ILSpy.Debugger.AvalonEdit int viewStart = visualLines.First().FirstDocumentLine.Offset; int viewEnd = visualLines.Last().LastDocumentLine.Offset + visualLines.Last().LastDocumentLine.Length; foreach (TextMarker marker in markers.FindOverlappingSegments(viewStart, viewEnd - viewStart).Reverse()) { + if (!marker.IsVisible(marker.Bookmark)) + continue; + if (marker.BackgroundColor != null) { BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder(); geoBuilder.AlignToWholePixels = true; @@ -295,8 +301,15 @@ namespace ILSpy.Debugger.AvalonEdit Redraw(); } } - } + } + /// public object ToolTip { get; set; } + + /// + public Predicate IsVisible { get; set; } + + /// + public IBookmark Bookmark { get; set; } } } diff --git a/Debugger/ILSpy.Debugger/Bookmarks/BreakpointBookmark.cs b/Debugger/ILSpy.Debugger/Bookmarks/BreakpointBookmark.cs index 879f1f6df..3100ba0ce 100644 --- a/Debugger/ILSpy.Debugger/Bookmarks/BreakpointBookmark.cs +++ b/Debugger/ILSpy.Debugger/Bookmarks/BreakpointBookmark.cs @@ -91,6 +91,10 @@ namespace ILSpy.Debugger.Bookmarks ITextMarker marker = markerService.Create(offset, length); marker.BackgroundColor = Color.FromRgb(180, 38, 38); marker.ForegroundColor = Colors.White; + marker.IsVisible = b => b is MarkerBookmark && ((MarkerBookmark)b).Type == DebugData.CurrentType; + marker.Bookmark = this; + this.Marker = marker; + return marker; } } diff --git a/Debugger/ILSpy.Debugger/Bookmarks/CurrentLineBookmark.cs b/Debugger/ILSpy.Debugger/Bookmarks/CurrentLineBookmark.cs index ceb01076b..9cfb6da45 100644 --- a/Debugger/ILSpy.Debugger/Bookmarks/CurrentLineBookmark.cs +++ b/Debugger/ILSpy.Debugger/Bookmarks/CurrentLineBookmark.cs @@ -81,6 +81,9 @@ namespace ILSpy.Debugger.Bookmarks ITextMarker marker = markerService.Create(offset + startColumn - 1, length); marker.BackgroundColor = Colors.Yellow; marker.ForegroundColor = Colors.Blue; + marker.IsVisible = b => b is MarkerBookmark && ((MarkerBookmark)b).Type == DebugData.CurrentType; + marker.Bookmark = this; + this.Marker = marker; return marker; } }