Skip to content

Commit c1d055d

Browse files
committed
[ fix ] Insert missing slash from files in browsers
1 parent cec2ca4 commit c1d055d

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

lib/js/src/Connection/Connection.bs.js

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/js/src/Connection/Protocol/Connection__Protocol__LSP__Binding.bs.js

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Connection/Connection.res

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,22 @@ module Module: Module = {
586586
"function(u){ try { return new URL(u).pathname; } catch(e) { return u; } }"
587587
)(protoUri)
588588

589+
// Ensure WASM-visible files live under /workspace. For URIs that map to
590+
// "/workspace<something>" we insert the missing slash so WASI resolves it.
591+
let filepath = {
592+
let prefix = "/workspace"
593+
if filepath->String.startsWith(prefix) {
594+
let rest = filepath->String.sliceToEnd(~start=String.length(prefix))
595+
if rest == "" || filepath->String.startsWith(prefix ++ "/") {
596+
filepath
597+
} else {
598+
prefix ++ "/" ++ rest
599+
}
600+
} else {
601+
filepath
602+
}
603+
}
604+
589605
Request.encode(document, version, filepath, backend, libraryPath, highlightingMethod, request)
590606
}
591607

src/Connection/Protocol/Connection__Protocol__LSP__Binding.res

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ module ServerOptions = {
208208
{
209209
runSetupFirst: true,
210210
setupCallback(exitCode, stderr) {
211-
if (exitCode === 0) {
212-
console.log('[agda-mode] ALS WASM setup completed successfully.');
213-
} else {
211+
if (exitCode !== 0) {
214212
console.warn('[agda-mode] ALS WASM setup exited with code ' + exitCode + ': ' + stderr);
215213
}
216214
},
@@ -228,7 +226,6 @@ module ServerOptions = {
228226
.catch((error) => {
229227
const message = error && (error.message || String(error));
230228
if (typeof message === 'string' && message.includes('--setup')) {
231-
console.warn('[agda-mode] ALS WASM binary does not support --setup; retrying without setup.');
232229
return attemptWithoutSetup();
233230
}
234231
throw error;
@@ -293,7 +290,6 @@ module LanguageClient = {
293290
let disposables = [];
294291
295292
const emitMessage = (data) => {
296-
console.log('[agda-mode] worker emitMessage', JSON.stringify(data, null, 2));
297293
const event = { data };
298294
if (typeof onmessageHandler === "function") {
299295
onmessageHandler(event);
@@ -310,7 +306,6 @@ module LanguageClient = {
310306
const ensureTransport = Promise.resolve()
311307
.then(() => (typeof factory === "function" ? factory() : factory))
312308
.then((transport) => {
313-
console.log('[agda-mode] worker transport ready', JSON.stringify(transport, null, 2));
314309
if (!transport || typeof transport !== "object") {
315310
throw new Error("agda-mode: invalid WASM transport");
316311
}
@@ -324,7 +319,6 @@ module LanguageClient = {
324319
}
325320
settledTransport = transport;
326321
const listenerDisposable = reader.listen((data) => {
327-
console.log('[agda-mode] reader received data', JSON.stringify(data, null, 2));
328322
emitMessage(data);
329323
});
330324
if (listenerDisposable && typeof listenerDisposable.dispose === "function") {
@@ -351,7 +345,6 @@ module LanguageClient = {
351345
});
352346
353347
const worker = {};
354-
console.log('[agda-mode] worker created');
355348
Object.defineProperty(worker, "onmessage", {
356349
get() {
357350
return onmessageHandler;
@@ -380,17 +373,14 @@ module LanguageClient = {
380373
};
381374
382375
worker.postMessage = (message) => {
383-
console.log('[agda-mode] worker postMessage', JSON.stringify(message, null, 2));
384376
ensureTransport
385377
.then((transport) => {
386-
console.log('[agda-mode] worker writing to transport');
387378
transport.writer.write(message).catch(emitError);
388379
})
389380
.catch(() => {});
390381
};
391382
392383
worker.terminate = () => {
393-
console.log('[agda-mode] worker terminate');
394384
disposables.forEach((disposable) => {
395385
try {
396386
if (disposable && typeof disposable.dispose === "function") {

0 commit comments

Comments
 (0)