diff --git a/Codist/Controls/ExternalAdornment.cs b/Codist/Controls/ExternalAdornment.cs index 5e61e579..16e89c34 100644 --- a/Codist/Controls/ExternalAdornment.cs +++ b/Codist/Controls/ExternalAdornment.cs @@ -26,6 +26,8 @@ public ExternalAdornment(IWpfTextView view) { var grid = view.VisualElement.GetParent(); if (grid != null) { grid.Children.Add(this); + view.Selection.SelectionChanged += ViewSeletionChanged; + view.VisualElement.Unloaded += VisualElement_Unloaded; } else { view.VisualElement.Loaded += VisualElement_Loaded; @@ -48,11 +50,9 @@ public void FocusOnTextView() { public void ClearUnpinnedChildren() { for (int i = Children.Count - 1; i >= 0; i--) { - var c = Children[i] as SymbolList; - if (c != null && c.IsPinned) { - continue; + if (Children[i] is SymbolList l && l.IsPinned == false) { + Children.RemoveAt(i); } - Children.RemoveAt(i); } }