From 74a5dc2ac011192ada0482333f40254d461ed069 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 25 Sep 2024 05:10:04 +0200 Subject: [PATCH] chore: allow creating user deco from just name --- src/mapping.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/mapping.ts b/src/mapping.ts index d8908fc..121d02b 100644 --- a/src/mapping.ts +++ b/src/mapping.ts @@ -10,7 +10,6 @@ class BufferMapper { this.editorToBufferMapping.set(uri, buffer); } - public uri_by_buffer(name: string): vscode.Uri | undefined { let uri = this.bufferToEditorMapping.get(name); return uri; @@ -39,27 +38,25 @@ export class UserDecoration { decoration: vscode.TextEditorDecorationType | null; color: string; buffer: string; - startRow : number; + startRow : number startCol : number; endRow : number; endCol : number; - - public constructor(event: codemp.Cursor) { - let hash = codemp.hash(event.user || "anon"); + public constructor(name: string) { + let hash = codemp.hash(name); this.color = colors[Math.abs(hash) % colors.length]; this.decoration = null; - this.buffer = event.buffer; - this.startRow = event.startRow; - this.startCol = event.startCol; - this.endRow = event.endRow; - this.endCol = event.endCol; - + this.buffer = ""; + this.startRow = 0; + this.startCol = 0; + this.endRow = 0; + this.endCol = 0; } // TODO can we avoid disposing and recreating the decoration type every time? public update(event: codemp.Cursor, editor?: vscode.TextEditor) { - this.buffer=event.buffer; + this.buffer = event.buffer; this.startRow = event.startRow; this.startCol = event.startCol; this.endRow = event.endRow; @@ -100,3 +97,4 @@ const colors = [ ]; export const colors_cache: Map = new Map(); +