Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkgs/id/web/src/cursor-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ export const CURSOR_COLORS = [
* Uses a hash function to map client IDs to colors.
*/
export function getColorForClient(clientID: string | number): string {
// A plain loop: no intermediate array of characters per call.
const str = String(clientID);
const str = typeof clientID === "string" ? clientID : String(clientID);
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0;
Expand Down
25 changes: 0 additions & 25 deletions pkgs/id/web/src/cursors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,22 +603,6 @@ function createCursorDecorations(
// Cluster overlapping groups - only merge those that actually overlap
const clusters = clusterOverlappingGroups(positionGroups, getLeftCoord);

// DEBUG: Log clustering results
if (positionGroups.length > 1) {
console.log("[cursor-debug] positionGroups:", positionGroups.length, "clusters:", clusters.length);
positionGroups.forEach((g, i) => {
const left = getLeftCoord ? getLeftCoord(g.position) : "no-view";
console.log(
` group[${i}]: pos=${g.position}, left=${left}, cursors=${g.cursors.map((c) => c.clientID).join(",")}`,
);
});
clusters.forEach((c, i) => {
console.log(
` cluster[${i}]: groups=${c.groups.length}, cursors=${c.groups.flatMap((g) => g.cursors.map((cur) => cur.clientID)).join(",")}`,
);
});
}

clusters.forEach((cluster) => {
// Check if own cursor is in this cluster
const clusterHasOwnCursor = cluster.groups.some((g) => g.cursors.some((c) => c.isOwnCursor));
Expand Down Expand Up @@ -811,7 +795,6 @@ export function createCursorPlugin(myClientID: string | number | null, sendCurso
if (cursorUpdate) {
switch (cursorUpdate.type) {
case "update": {
console.log("[cursor-debug] apply() UPDATE for", cursorUpdate.clientID, "at", cursorUpdate.head);
const newCursors = new Map(pluginState.cursors);
// If idleSecs is provided (initial load), backdate lastUpdate
const lastUpdate = cursorUpdate.idleSecs ? Date.now() - cursorUpdate.idleSecs * 1000 : Date.now();
Expand Down Expand Up @@ -923,14 +906,6 @@ export function createCursorPlugin(myClientID: string | number | null, sendCurso
const pluginState = cursorPluginKey.getState(state);
if (!pluginState) return DecorationSet.empty;

// DEBUG: Log cursor count
console.log(
"[cursor-debug] decorations() called, cursor count:",
pluginState.cursors.size,
"cursors:",
Array.from(pluginState.cursors.keys()).join(","),
);

return createCursorDecorations(state, pluginState, myClientID, currentView);
},
},
Expand Down
Loading