Przeglądaj źródła

Ensure collaborator cursor colour is updated (#26847)

GitOrigin-RevId: 7057cdbb4815d5f1c5e5771d38255e58f592f9cd
Alf Eaton 1 rok temu
rodzic
commit
3e9d60c25a

+ 13 - 1
services/web/frontend/js/features/source-editor/extensions/cursor-highlights.ts

@@ -166,7 +166,7 @@ export const setCursorHighlights = (
 
 class CursorMarker extends RectangleMarker {
   constructor(
-    private highlight: Highlight,
+    public highlight: Highlight,
     className: string,
     left: number,
     top: number,
@@ -181,6 +181,18 @@ class CursorMarker extends RectangleMarker {
     element.style.setProperty('--hue', String(this.highlight.hue))
     return element
   }
+
+  update(element: HTMLDivElement, prev: CursorMarker) {
+    if (!super.update(element, prev)) {
+      return false
+    }
+    element.style.setProperty('--hue', String(this.highlight.hue))
+    return true
+  }
+
+  eq(other: CursorMarker) {
+    return super.eq(other) && this.highlight.hue === other.highlight.hue
+  }
 }
 
 // draw the collaborator cursors in a separate layer, so they don't affect word wrapping