From 0a5ad7c95b153e0cc15fd5df9bb8a6d68d42da97 Mon Sep 17 00:00:00 2001 From: Jonathan Tran Date: Thu, 9 Jan 2025 09:15:00 -0500 Subject: [PATCH] Show deprecated indicator in CodeMirror autocomplete (#4983) --- packages/codemirror-lsp-client/src/plugin/lsp.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/codemirror-lsp-client/src/plugin/lsp.ts b/packages/codemirror-lsp-client/src/plugin/lsp.ts index c7ae37641..c8c7e0fb6 100644 --- a/packages/codemirror-lsp-client/src/plugin/lsp.ts +++ b/packages/codemirror-lsp-client/src/plugin/lsp.ts @@ -368,13 +368,20 @@ export class LanguageServerPlugin implements PluginValue { sortText, filterText, }) => { + const detailText = [ + deprecated ? 'Deprecated' : undefined, + labelDetails ? labelDetails.detail : detail, + ] + // Don't let undefined appear. + .filter(Boolean) + .join(' ') const completion: Completion & { filterText: string sortText?: string apply: string } = { label, - detail: labelDetails ? labelDetails.detail : detail, + detail: detailText, apply: label, type: kind && CompletionItemKindMap[kind].toLowerCase(), sortText: sortText ?? label, @@ -382,7 +389,11 @@ export class LanguageServerPlugin implements PluginValue { } if (documentation) { completion.info = () => { - const htmlString = formatMarkdownContents(documentation) + const deprecatedHtml = deprecated + ? '

Deprecated

' + : '' + const htmlString = + deprecatedHtml + formatMarkdownContents(documentation) const htmlNode = document.createElement('div') htmlNode.style.display = 'contents' htmlNode.innerHTML = htmlString