chore: allow creating user deco from just name

This commit is contained in:
əlemi 2024-09-25 05:10:04 +02:00
parent 117a540d6f
commit 74a5dc2ac0
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -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,22 +38,20 @@ 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?
@ -100,3 +97,4 @@ const colors = [
];
export const colors_cache: Map<string, UserDecoration> = new Map();