You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constvalue=/* set from `myEditor.getModel()`: */`{}`;// Hover on each property to see its docs!constmyEditor=monaco.editor.create(document.getElementById("container"),{
value,language: "json",automaticLayout: true,});// Register dynamic completions based on ASTmonaco.languages.registerCompletionItemProvider('json',{provideCompletionItems: async(model,position,context)=>{console.log(monaco.languages.json);constjsonWorker=await(awaitmonaco.languages.json.getWorker())(model.uri);constjsonDocument=awaitjsonWorker.parseJSONDocument(model.uri.toString());console.log(jsonDocument);// This works just fine in Monaco Editor Playgroundconstnode=jsonDocument?.getNodeFromOffset(model.getOffsetAt(position));console.log(node);constword=model.getWordUntilPosition(position);return{suggestions: [{kind: monaco.languages.CompletionItemKind.Text,insertText: '"foo"',label: 'Foo',range: {startLineNumber: position.lineNumber,endLineNumber: position.lineNumber,startColumn: word.startColumn,endColumn: word.endColumn,},},],};},});
Reproduction Steps
I'm trying to create dynamic completions based on the JSON AST. For that I'm utilizing the functionality exposed with this PR: #4299, specifically JSONDocument.getNodeFromOffset. TypeScript tells me the method is there, but I'm getting a runtime error: Uncaught Error: jsonDocument?.getNodeFromOffset is not a function.
Reproducible in vscode.dev or in VS Code Desktop?
Reproducible in the monaco editor playground?
Monaco Editor Playground Link
https://microsoft.github.io/monaco-editor/playground.html?source=v0.50.0#XQAAAAJQBQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw83J8RgmSaumWUF-TBOsVJ4S4FwfCDQb5-2uUHXTVAefbVSd9IzaZ_vv9VR9KugsKiuGc2v5CrpC-28kzerv7FIINy73ctGSXrXyLSJzMzDkuKaa3tMg-UK4lhIYaP9NgpLNPfl7xF4BFMGqe-EJcVnNjGP6HeT9D9pWb93Wo4ZQgXuxOwtwin2u1xyz2Gx2slmhr8HXj7qdLwdlI27k25rc_v3AgJaKUIY-HvvR-F0sYfn_RN_g0QEv9MxSIEaFssFLtvkiFbazxmuPXPkHE0d_5xmqDVrtxkmN5uPUH9JDZF7Yd1uWIv8GMpep5xZVFvSw2-cIz0w28dQsPRy09JtpdmqY_n8RDaTrTESu5TYMgqSUFAK5NLKs_SnqA-TxUA5t2LxcbDcESk_xWw1TvxfXMdIYn2kDAktHQZpw_WFa0VsjWzI5VGXfodLhidItlPOQvpLzdH4Ubvi9ri3HxQM--aLPv4u380HU3Ut-LoNAsG1DNderr5zcICxXC9wfSh-3lGctsMGComlylPMCAu147wsBYYxTuk4rrCNAvpTYvdvkDtNYbuaz6tKxtSbM86ty-wmMi4B45WXyoykT741zQSpdgyfhF67hv6JUWVhA8cL88H1mCrWtUsyiLkYFp0dHOfje430WShbPDsEICuuNK4F_jM1Px4NL713M2FRudga9BWP5wCjpUHsE_dhg3U0HKbDsr-6QaXG-UGmWOcfuVFjEfOuM94FkVYH78P9jQRx7xr6bgf6XjoZiGKyFyKrxRVvkCwRJfIsplC3WSQAaGLXEEothGIRxm7NjXTdFCUwN1wUH_-Exwyg
Monaco Editor Playground Code
Reproduction Steps
I'm trying to create dynamic completions based on the JSON AST. For that I'm utilizing the functionality exposed with this PR: #4299, specifically
JSONDocument.getNodeFromOffset
. TypeScript tells me the method is there, but I'm getting a runtime error:Uncaught Error: jsonDocument?.getNodeFromOffset is not a function
.Reproduction environment with Vite: https://stackblitz.com/edit/vitejs-vite-bhgqgc?file=src%2Fmain.ts
Actual (Problematic) Behavior
Runtime error:
Uncaught Error: jsonDocument?.getNodeFromOffset is not a function
Expected Behavior
jsonDocument?.getNodeFromOffset
should work as it does in the Monaco Editor Playground.Additional Context
No response
The text was updated successfully, but these errors were encountered: