diff --git a/extensions/positron-python/news/1 Enhancements/17658.md b/extensions/positron-python/news/1 Enhancements/17658.md new file mode 100644 index 00000000000..48023372756 --- /dev/null +++ b/extensions/positron-python/news/1 Enhancements/17658.md @@ -0,0 +1 @@ +Provide IntelliSense status information when using `github.dev` or any other web platform. diff --git a/extensions/positron-python/package.nls.json b/extensions/positron-python/package.nls.json index 1a101b51c32..11a0468d4da 100644 --- a/extensions/positron-python/package.nls.json +++ b/extensions/positron-python/package.nls.json @@ -165,6 +165,9 @@ "Testing.configureTests": "Configure Test Framework", "Testing.testNotConfigured": "No test framework configured.", "Common.openOutputPanel": "Show output", + "LanguageService.statusItem.name":"Python IntelliSense Status", + "LanguageService.statusItem.text": "Partial Mode", + "LanguageService.statusItem.detail": "Limited IntelliSense provided by Pylance", "LanguageService.lsFailedToStart": "We encountered an issue starting the language server. Reverting to Jedi language engine. Check the Python output panel for details.", "LanguageService.lsFailedToDownload": "We encountered an issue downloading the language server. Reverting to Jedi language engine. Check the Python output panel for details.", "LanguageService.lsFailedToExtract": "We encountered an issue extracting the language server. Reverting to Jedi language engine. Check the Python output panel for details.", diff --git a/extensions/positron-python/src/client/browser/extension.ts b/extensions/positron-python/src/client/browser/extension.ts index fb25d3d8765..88891aebd4a 100644 --- a/extensions/positron-python/src/client/browser/extension.ts +++ b/extensions/positron-python/src/client/browser/extension.ts @@ -11,6 +11,7 @@ import { LanguageServerType } from '../activation/types'; import { AppinsightsKey, PVSC_EXTENSION_ID, PYLANCE_EXTENSION_ID } from '../common/constants'; import { loadLocalizedStringsForBrowser } from '../common/utils/localizeHelpers'; import { EventName } from '../telemetry/constants'; +import { createStatusItem } from './intellisenseStatus'; interface BrowserConfig { distUrl: string; // URL to Pylance's dist folder. @@ -115,6 +116,7 @@ async function runPylance( const disposable = languageClient.start(); context.subscriptions.push(disposable); + context.subscriptions.push(createStatusItem()); } catch (e) { console.log(e); } diff --git a/extensions/positron-python/src/client/browser/intellisenseStatus.ts b/extensions/positron-python/src/client/browser/intellisenseStatus.ts new file mode 100644 index 00000000000..19e410399f4 --- /dev/null +++ b/extensions/positron-python/src/client/browser/intellisenseStatus.ts @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// IMPORTANT: Do not import any node fs related modules here, as they do not work in browser. +import * as vscode from 'vscode'; +import { LanguageService } from './localize'; + +export function createStatusItem(): vscode.Disposable { + if ('createLanguageStatusItem' in vscode.languages) { + const statusItem = vscode.languages.createLanguageStatusItem('python.projectStatus', { + language: 'python', + }); + statusItem.name = LanguageService.statusItem.name(); + statusItem.severity = vscode.LanguageStatusSeverity.Warning; + statusItem.text = LanguageService.statusItem.text(); + statusItem.detail = LanguageService.statusItem.detail(); + statusItem.command = { + title: 'Learn More', + command: 'vscode.open', + arguments: [vscode.Uri.parse('https://aka.ms/AAdzyh4')], + }; + return statusItem; + } + // eslint-disable-next-line @typescript-eslint/no-empty-function + return { dispose: () => {} }; +} diff --git a/extensions/positron-python/tsconfig.browser.json b/extensions/positron-python/tsconfig.browser.json index d4aae7e9820..cda0a494e0f 100644 --- a/extensions/positron-python/tsconfig.browser.json +++ b/extensions/positron-python/tsconfig.browser.json @@ -1,6 +1,7 @@ { "extends": "./tsconfig.json", "include": [ - "./src/client/browser" + "./src/client/browser", + "./types/vscode.proposed.d.ts" ] } diff --git a/extensions/positron-python/types/vscode.proposed.d.ts b/extensions/positron-python/types/vscode.proposed.d.ts index 3f817992a0e..3a0ae806c47 100644 --- a/extensions/positron-python/types/vscode.proposed.d.ts +++ b/extensions/positron-python/types/vscode.proposed.d.ts @@ -750,6 +750,33 @@ declare module 'vscode' { replaceOutputItems(items: NotebookCellOutputItem | NotebookCellOutputItem[], outputId: string): Thenable; } + //#region https://github.com/microsoft/vscode/issues/129037 + + enum LanguageStatusSeverity { + Information = 0, + Warning = 1, + Error = 2, + } + + interface LanguageStatusItem { + readonly id: string; + selector: DocumentSelector; + // todo@jrieken replace with boolean ala needsAttention + severity: LanguageStatusSeverity; + name: string | undefined; + text: string; + detail?: string; + command: Command | undefined; + accessibilityInformation?: AccessibilityInformation; + dispose(): void; + } + + namespace languages { + export function createLanguageStatusItem(id: string, selector: DocumentSelector): LanguageStatusItem; + } + + //#endregion + export interface QuickPick extends QuickInput { /** * An optional flag to sort the final results by index of first query match in label. Defaults to true.