diff --git a/rollup.config.ts b/rollup.config.ts index ff64d8f..ff935ee 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -103,17 +103,23 @@ ${files.map((_, index) => ` whenReady${index}()`).join(',\n')} breakpoints, taskDefinitions, viewsWelcome, + terminal, + viewsContainers, ...remainingContribute - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } = manifest.contributes as any + } = manifest.contributes ?? {} const { + activationEvents, + devDependencies, + dependencies, + scripts, browser, main, l10n, extensionDependencies, // for pure-d that requires hbenl.vscode-test-explorer ...remainingManifest - } = manifest + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } = manifest as any return { ...remainingManifest, diff --git a/src/tools.ts b/src/tools.ts index 897e575..cf8a5db 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -182,18 +182,20 @@ export function lockCodeWithoutDecoration ( return disposableStore } +let hideCodeWithoutDecorationCounter = 0 export function hideCodeWithoutDecoration (editor: monaco.editor.ICodeEditor, decorationFilter: (decoration: monaco.editor.IModelDecoration) => boolean): monaco.IDisposable { - let otherHiddenAreas: monaco.IRange[] = editor._getViewModel()?.getHiddenAreas() ?? [] - function getHiddenAreas () { + const hideId = `hideCodeWithoutDecoration:${hideCodeWithoutDecorationCounter++}` + + function updateHiddenAreas (): void { const model = editor.getModel() if (model == null) { - return [] + return } const decorations = model.getAllDecorations() .filter(decorationFilter) if (decorations.length === 0) { - return otherHiddenAreas + return } const ranges = decorations @@ -218,40 +220,22 @@ export function hideCodeWithoutDecoration (editor: monaco.editor.ICodeEditor, de } }, []) - let hiddenAreas: monaco.IRange[] = [...otherHiddenAreas] + const hiddenAreas: monaco.IRange[] = [] let position = new monaco.Position(1, 1) for (const range of ranges) { const startPosition = model.modifyPosition(range.getStartPosition(), -1) const endPosition = model.modifyPosition(range.getEndPosition(), 1) - hiddenAreas = [ - ...hiddenAreas, - monaco.Range.fromPositions(position, startPosition) - ] + hiddenAreas.push(monaco.Range.fromPositions(position, startPosition)) position = endPosition } - hiddenAreas = [ - ...hiddenAreas, - monaco.Range.fromPositions(position, model.getFullModelRange().getEndPosition()) - ] - - return hiddenAreas - } - - const originalSetHiddenAreas = editor.setHiddenAreas.bind(editor) - function updateHiddenAreas () { - originalSetHiddenAreas(getHiddenAreas()) - } + hiddenAreas.push(monaco.Range.fromPositions(position, model.getFullModelRange().getEndPosition())) - // Hack to make it work with the folding service calling setHiddenAreas with its own areas - editor.setHiddenAreas = (ranges) => { - otherHiddenAreas = ranges - updateHiddenAreas() + editor.setHiddenAreas(hiddenAreas, hideId) } const disposableStore = new DisposableStore() disposableStore.add(editor.onDidChangeModel(() => { - otherHiddenAreas = editor._getViewModel()?.getHiddenAreas() ?? [] updateHiddenAreas() })) disposableStore.add(editor.onDidChangeModelDecorations(() => { @@ -261,8 +245,7 @@ export function hideCodeWithoutDecoration (editor: monaco.editor.ICodeEditor, de disposableStore.add({ dispose () { - editor.setHiddenAreas = originalSetHiddenAreas - editor.setHiddenAreas(otherHiddenAreas) + editor.setHiddenAreas([], hideId) } }) diff --git a/src/types/monaco.d.ts b/src/types/monaco.d.ts index 2ca02f2..e7b54f4 100644 --- a/src/types/monaco.d.ts +++ b/src/types/monaco.d.ts @@ -5,7 +5,7 @@ declare module 'monaco-editor' { interface ICodeEditor { // This method is internal and is supposed to be used by the folding feature // We still use it to hide parts of the code in the `hideCodeWithoutDecoration` function - setHiddenAreas(ranges: IRange[]): void + setHiddenAreas(ranges: IRange[], source?: unknown): void _getViewModel(): { getHiddenAreas(): IRange[]