i'm building an electron app. On the renderer side im additionally using SolidJS with vite.
When trying to create a model reference with an registered memory file the Error "Model not found" occurs. I'm pretty much stuck as debugging shows that the file is registered correctly.
Code Snippet:
onMount(async () => {
await initialize();
const fileSystemProvider = new RegisteredFileSystemProvider(false);
const fileURL = '/test-files/test.cpp'; //reference from vite public folder
const fileName = 'test.cpp';
const response = await fetch(fileURL);
const fileContent = await response.text();
console.log("Fetched file content:", fileContent);
const memoryFileUri = vscode.Uri.file(fileName);
let memoryFile
fileSystemProvider.registerFile(
memoryFile = new RegisteredMemoryFile(memoryFileUri, fileContent)
);
console.log("Registered memory file:", memoryFile);
const overlay = registerFileSystemOverlay(1, fileSystemProvider);
console.log("Calling model reference with:", memoryFileUri.toString());
// error is thrown here
const modelRef = await createModelReference(memoryFileUri);
modelRef.object.setLanguageId('cpp');
console.log("Model:", modelRef.object.textEditorModel);
const editor = createConfiguredEditor(container, {
model: modelRef.object.textEditorModel,
theme: 'vs-dark',
automaticLayout: true,
});
createWebSocket('ws://localhost:30003/clangd');
onCleanup(() => {
editor.dispose();
modelRef.dispose();
});
});
Logs:
Fetched file content: #include <stdio.h>
int main() {
int b= a();
return 0;
}
int a() {
return 0;
}
MonacoEditor.jsx:87 Registered memory file:
RegisteredMemoryFile {uri: Uri, readonly: false, type: 1, _onDidChange: Emitter, onDidChange: ƒ, …}
MonacoEditor.jsx:91 Calling model reference with: file:///test.cpp
chunk-BD6NCM2E.js?v=8d2335a4:70820 Uncaught (in promise) Error: Model not found
at async MonacoEditor.jsx:93:22
Tried: To create a model reference for the vscode monaco editor.
Result: Thrown the error: Model not found
Expected: Model gets created and added to the editor instance.