mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-22 15:34:49 +01:00
New features: sending buffer events
This commit is contained in:
parent
cf99be0059
commit
35c48a205f
1 changed files with 11 additions and 1 deletions
|
@ -43,7 +43,7 @@ async function connect() {
|
||||||
if (host === undefined) return // user cancelled with ESC
|
if (host === undefined) return // user cancelled with ESC
|
||||||
if (host.length == 0) host = "http://alemi.dev:50051"
|
if (host.length == 0) host = "http://alemi.dev:50051"
|
||||||
await codemp.connect(host);
|
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");
|
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) =>{
|
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?
|
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?
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue