[fix] server diags

This commit is contained in:
Andy Bunce 2025-08-28 16:44:48 +01:00
parent 776d5013d0
commit 18f3f309c7
2 changed files with 20 additions and 5 deletions

View file

@ -64,13 +64,20 @@ function connect() {
.then(transport => {
transport.socket.onclose = (event) => connectStatus(false);
transport.socket.oneror = (event) => $("msg").innerText = "sock error!";
transport.subscribe(incoming);
client = new lsp.LSPClient({extensions: lsp.languageServerExtensions()});
client.connect(transport);
$("popConnect").hidePopover();
connectStatus(true);
let extLsp =client.plugin( file, "xquery");
view.dispatch({ effects: lsp.StateEffect.appendConfig.of(extLsp) })
let up=lsp.debouncedChangeListener({
delay: 750,
onChange: (content, state) => {
console.log('Debounced change detected:'+content);
client.sync();
}})
view.dispatch({ effects: lsp.StateEffect.appendConfig.of([...extLsp,up]) })
})
.catch(r => { connectStatus(false); alert("connection failed: " + server) });
@ -86,12 +93,20 @@ function connectStatus(bool) {
}
};
function incoming(msg) {
const rpc = JSON.parse(msg);
log(rpc);
};
function log(rpc) {
console.log("<-",rpc)
if (rpc.id) return
const text = rpc.method;
const li = document.createElement("li");
li.appendChild(document.createTextNode(text));
const n=$("traffic").childElementCount + " ";
li.appendChild(document.createTextNode(n + text));
$("traffic").insertBefore(li, $("traffic").firstChild)
};