From 40ba9eaf82a1386ccacf5046c072df3d131d5284 Mon Sep 17 00:00:00 2001
From: Nate Sesti <sestinj@gmail.com>
Date: Mon, 12 Jun 2023 10:50:33 -0700
Subject: calculate diff and highlight changes

---
 extension/src/decorations.ts | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

(limited to 'extension/src/decorations.ts')

diff --git a/extension/src/decorations.ts b/extension/src/decorations.ts
index 456f0c10..d2c94135 100644
--- a/extension/src/decorations.ts
+++ b/extension/src/decorations.ts
@@ -94,15 +94,22 @@ class DecorationManager {
       decorationTypes = new Map();
       decorationTypes.set(key.decorationType, [key.options]);
       this.editorToDecorations.set(key.editorUri, decorationTypes);
-    }
-
-    const decorations = decorationTypes.get(key.decorationType);
-    if (!decorations) {
-      decorationTypes.set(key.decorationType, [key.options]);
     } else {
-      decorations.push(key.options);
+      const decorations = decorationTypes.get(key.decorationType);
+      if (!decorations) {
+        decorationTypes.set(key.decorationType, [key.options]);
+      } else {
+        decorations.push(key.options);
+      }
     }
+
     this.rerenderDecorations(key.editorUri, key.decorationType);
+
+    vscode.window.onDidChangeTextEditorSelection((event) => {
+      if (event.textEditor.document.fileName === key.editorUri) {
+        this.deleteAllDecorations(key.editorUri);
+      }
+    });
   }
 
   deleteDecoration(key: DecorationKey) {
-- 
cgit v1.2.3-70-g09d2