diff --git a/src/monaco/code2monaco.ts b/src/monaco/code2monaco.ts index be94d569..244c41e3 100644 --- a/src/monaco/code2monaco.ts +++ b/src/monaco/code2monaco.ts @@ -426,3 +426,13 @@ export function asColorPresentation(item: vscode.ColorPresentation): monaco.lang additionalTextEdits: item.additionalTextEdits ? item.additionalTextEdits.map(asTextEdit) : undefined, }; } + +export function asFoldingRange(item: vscode.FoldingRange): monaco.languages.FoldingRange { + return { + start: item.startLine, + end: item.endLine, + kind: { + value: item.kind ?? '', + }, + }; +} diff --git a/src/monaco/ls.ts b/src/monaco/ls.ts index 8200542e..2f08cfea 100644 --- a/src/monaco/ls.ts +++ b/src/monaco/ls.ts @@ -509,6 +509,17 @@ export async function setupLs(modelsMap: Ref { + const document = getTextDocument(model); + if (document) { + const codeResult = await ds.getFoldingRanges(document); + if (codeResult) { + return codeResult.map(code2monaco.asFoldingRange); + } + } + }, + }), ); return ls;