From 4750d70b9598d053964ab12a3fc2117d42faebd1 Mon Sep 17 00:00:00 2001
From: WMJ <wmj@live.cn>
Date: Wed, 15 Sep 2021 15:15:32 +0800
Subject: [PATCH] - Fixed symbol lists was not automatically hidden in diff
 windows

---
 Codist/Controls/ExternalAdornment.cs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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<Grid>();
 			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);
 			}
 		}