Skip to content

Commit

Permalink
Provide IntelliSense status information when using github.dev (micr…
Browse files Browse the repository at this point in the history
…osoft/vscode-python#17658)

* Provide IntelliSense status information when using github.dev

* News entry

* Update wording

* PR reviews

* Include proposed APIs for browser config

* Include common module for browser config

* Change how we detect

* Change wording

* Have same browser config as extension config

* Revert "Have same browser config as extension config"

This reverts commit 515003aee2fa4a44105f22c4749f1fa721be6bcf.

* Revert "Change wording"

This reverts commit dd64f24d4c4c8cb763d9fa3aa5a2eb5808b5af9b.

* Revert "Change how we detect"

This reverts commit ae5607994f30b54158315c72a46583e7cf286fb2.

* Revert "Include common module for browser config"

This reverts commit bf1815c9b8aaa9091c37d54cf010ff3bd46c8ab4.

* Do not import from misc module

* Detect how we check if property exists

* Do not localize strings

* Localize strings using new localize module

* Remove outdated comment
  • Loading branch information
Kartik Raj authored and wesm committed Mar 28, 2024
1 parent 283cb79 commit e360629
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions extensions/positron-python/news/1 Enhancements/17658.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Provide IntelliSense status information when using `github.dev` or any other web platform.
3 changes: 3 additions & 0 deletions extensions/positron-python/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 2 additions & 0 deletions extensions/positron-python/src/client/browser/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -115,6 +116,7 @@ async function runPylance(
const disposable = languageClient.start();

context.subscriptions.push(disposable);
context.subscriptions.push(createStatusItem());
} catch (e) {
console.log(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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: () => {} };
}
3 changes: 2 additions & 1 deletion extensions/positron-python/tsconfig.browser.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "./tsconfig.json",
"include": [
"./src/client/browser"
"./src/client/browser",
"./types/vscode.proposed.d.ts"
]
}
27 changes: 27 additions & 0 deletions extensions/positron-python/types/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,33 @@ declare module 'vscode' {
replaceOutputItems(items: NotebookCellOutputItem | NotebookCellOutputItem[], outputId: string): Thenable<void>;
}

//#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<T extends QuickPickItem> extends QuickInput {
/**
* An optional flag to sort the final results by index of first query match in label. Defaults to true.
Expand Down

0 comments on commit e360629

Please sign in to comment.