From 013566ba936e200e3be3093ba383372b18567595 Mon Sep 17 00:00:00 2001
From: Khan Winter <35942988+thecoolwinter@users.noreply.github.com>
Date: Sun, 10 Nov 2024 15:03:12 -0600
Subject: [PATCH] Sync System Cursor Animation (#56)

---
 .../TextSelectionManager/TextSelectionManager.swift    | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Sources/CodeEditTextView/TextSelectionManager/TextSelectionManager.swift b/Sources/CodeEditTextView/TextSelectionManager/TextSelectionManager.swift
index 0d61da43..546e856f 100644
--- a/Sources/CodeEditTextView/TextSelectionManager/TextSelectionManager.swift
+++ b/Sources/CodeEditTextView/TextSelectionManager/TextSelectionManager.swift
@@ -188,6 +188,16 @@ public class TextSelectionManager: NSObject {
         if didUpdate {
             delegate?.setNeedsDisplay()
             cursorTimer.resetTimer()
+            resetSystemCursorTimers()
+        }
+    }
+
+    private func resetSystemCursorTimers() {
+        guard #available(macOS 14, *) else { return }
+        for cursorView in textSelections.compactMap({ $0.view as? NSTextInsertionIndicator }) {
+            let frame = cursorView.frame
+            cursorView.frame = .zero
+            cursorView.frame = frame
         }
     }