From 35c48a205f0b31c2e26fb879b6bde61d1b3a1f30 Mon Sep 17 00:00:00 2001 From: frelodev Date: Sun, 1 Oct 2023 10:56:19 +0200 Subject: [PATCH] New features: sending buffer events --- src/extension.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index bd129cd..fe3ae97 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -43,7 +43,7 @@ async function connect() { if (host === undefined) return // user cancelled with ESC if (host.length == 0) host = "http://alemi.dev:50051" await codemp.connect(host); - vscode.window.showInformationMessage(`Connected to codemp @[${host}]`); + vscode.window.showInformationMessage(`Connected to codemp @[${host}]`); } @@ -149,6 +149,16 @@ async function attach() { console.log("kiao"); + vscode.workspace.onDidChangeTextDocument((event:vscode.TextDocumentChangeEvent) =>{ + console.log(event.reason); + for (let change of event.contentChanges) { + if (`${change.rangeOffset}${change.text}${change.rangeOffset+change.rangeLength}` === CACHE) continue; + let op = buffer.delta(change.rangeOffset,change.text,change.rangeOffset+change.rangeLength) + if (op != null) { buffer.send(op) } + else { console.log("change is empty") } + } + }); + buffer.callback((event:any) =>{ CACHE = `${event.span.start}${event.content}${event.span.end}`; //what's the difference between e.text and e.content like it's on lib.rs?