New features: sending buffer events

This commit is contained in:
frelodev 2023-10-01 10:56:19 +02:00
parent cf99be0059
commit 35c48a205f

View file

@ -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?