Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into jupyter-lspgh-1038-…
Browse files Browse the repository at this point in the history
…fix-cov
  • Loading branch information
bollwyvl committed Feb 7, 2024
2 parents 869198f + 5afe3b4 commit 16515bf
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion packages/jupyterlab-lsp/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
27 changes: 16 additions & 11 deletions packages/jupyterlab-lsp/src/features/completion/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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];
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion packages/jupyterlab-lsp/src/virtual/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/metapackage/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 16515bf

Please sign in to comment.