diff --git a/CHANGELOG.md b/CHANGELOG.md index 64e7cdd75..7d0c953eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## Changelog +### `@jupyter-lsp/jupyterlab-lsp 5.0.3` + +- bug fixes: + - fix nested transclusions in JupyterLab 4.0.7+ (#1045) + - fix completions when `type` is not defined (#1044) + ### `@jupyter-lsp/jupyterlab-lsp 5.0.2` - bug fixes: diff --git a/packages/jupyterlab-lsp/package.json b/packages/jupyterlab-lsp/package.json index 9d8010fa9..d95cb3b98 100644 --- a/packages/jupyterlab-lsp/package.json +++ b/packages/jupyterlab-lsp/package.json @@ -1,6 +1,6 @@ { "name": "@jupyter-lsp/jupyterlab-lsp", - "version": "5.0.2", + "version": "5.0.3", "description": "Language Server Protocol integration for JupyterLab", "keywords": [ "jupyter", diff --git a/packages/jupyterlab-lsp/src/features/completion/renderer.ts b/packages/jupyterlab-lsp/src/features/completion/renderer.ts index b319f0f9b..35cd105d1 100644 --- a/packages/jupyterlab-lsp/src/features/completion/renderer.ts +++ b/packages/jupyterlab-lsp/src/features/completion/renderer.ts @@ -49,21 +49,22 @@ export class LSPCompletionRenderer ); } - protected getExtraInfo(item: CompletionItem): string { + protected getExtraInfo( + item: CompletionItem | IExtendedCompletionItem + ): string | undefined { const labelExtra = this.options.settings.composite.labelExtra; + const detail = 'detail' in item ? item?.detail ?? '' : ''; switch (labelExtra) { case 'detail': - return item?.detail || ''; + return detail; case 'type': return item?.type?.toLowerCase?.(); case 'source': return item?.source; case 'auto': - return [ - item?.detail || '', - item?.type?.toLowerCase?.(), - item?.source - ].filter(x => !!x)[0]; + return [detail, item?.type?.toLowerCase?.(), item?.source].filter( + x => !!x + )[0]; default: this.options.console.warn( 'labelExtra does not match any of the expected values', @@ -73,7 +74,10 @@ export class LSPCompletionRenderer } } - public updateExtraInfo(item: CompletionItem, li: HTMLLIElement) { + public updateExtraInfo( + item: CompletionItem | IExtendedCompletionItem, + li: HTMLLIElement + ) { const extraText = this.getExtraInfo(item); if (extraText) { const extraElement = li.getElementsByClassName(this.EXTRA_INFO_CLASS)[0]; @@ -184,10 +188,11 @@ export class LSPCompletionRenderer } } - itemWidthHeuristic(item: CompletionItem): number { + itemWidthHeuristic(item: CompletionItem | IExtendedCompletionItem): number { let labelSize = item.label.replace(/<(\/)?mark>/g, '').length; - const extraTextSize = this.getExtraInfo(item).length; - const type = item.type.toLowerCase(); + const extra = this.getExtraInfo(item); + const extraTextSize = extra?.length ?? 0; + const type = item.type?.toLowerCase(); if (type === 'file' || type === 'path') { // account for elision const parts = item.label.split(/<\/mark>/g); diff --git a/packages/jupyterlab-lsp/src/virtual/document.ts b/packages/jupyterlab-lsp/src/virtual/document.ts index 44d601fef..b80603872 100644 --- a/packages/jupyterlab-lsp/src/virtual/document.ts +++ b/packages/jupyterlab-lsp/src/virtual/document.ts @@ -225,7 +225,6 @@ export class VirtualDocument extends VirtualDocumentBase { ); if (extractor.standalone && unusedStandalone.length > 0) { foreignDocument = unusedStandalone.pop()!; - this.unusedDocuments.delete(foreignDocument); } else { // if (previous document does not exists) or (extractor produces standalone documents // and no old standalone document could be reused): create a new document diff --git a/packages/metapackage/package.json b/packages/metapackage/package.json index 063dd9d3c..6dd8449b2 100644 --- a/packages/metapackage/package.json +++ b/packages/metapackage/package.json @@ -1,6 +1,6 @@ { "name": "@jupyter-lsp/jupyterlab-lsp-metapackage", - "version": "5.0.2", + "version": "5.0.3", "description": "JupyterLab LSP - Meta Package. All of the packages used by JupyterLab LSP", "homepage": "https://github.com/jupyter-lsp/jupyterlab-lsp", "bugs": { diff --git a/setup.cfg b/setup.cfg index f3dea7b29..8f87d9330 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,7 +26,8 @@ show_contexts = True [flake8] exclude = .git,__pycache__,envs,.ipynb_checkpoints,.mypy_cache max-line-length = 88 -ignore = E203,W503 +# E704 conflicts with black (https://github.com/PyCQA/pycodestyle/issues/1036) +ignore = E203,W503,E704 [isort] profile = black