Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 921adeb

Browse files
committed
fx #1194
1 parent 8036f3b commit 921adeb

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

src/client/common/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
export const PythonLanguage = { language: 'python', scheme: 'file' };
2+
export const PythonLanguage = { language: 'python' };
33

44
export namespace Commands {
55
export const Set_Interpreter = 'python.setInterpreter';

src/client/extension.ts

+19-22
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ import { getPathFromPythonCommand } from './common/utils';
3232
import { JupyterProvider } from './jupyter/provider';
3333
import { activateGoToObjectDefinitionProvider } from './providers/objectDefinitionProvider';
3434

35-
const PYTHON: vscode.DocumentFilter = { language: 'python', scheme: 'file' };
35+
const PYTHON: vscode.DocumentFilter = { language: 'python' };
3636
let unitTestOutChannel: vscode.OutputChannel;
3737
let formatOutChannel: vscode.OutputChannel;
3838
let lintingOutChannel: vscode.OutputChannel;
3939
let jupMain: jup.Jupyter;
4040
export function activate(context: vscode.ExtensionContext) {
41-
let pythonSettings = settings.PythonSettings.getInstance();
42-
let pythonExt = new PythonExt();
43-
const hasPySparkInCompletionPath = pythonSettings.autoComplete.extraPaths.some(p => p.toLowerCase().indexOf('spark') >= 0);
41+
const pythonSettings = settings.PythonSettings.getInstance();
42+
const pythonExt = new PythonExt();
43+
context.subscriptions.push(pythonExt);
4444
// telemetryHelper.sendTelemetryEvent(telemetryContracts.EVENT_LOAD, {
4545
// CodeComplete_Has_ExtraPaths: pythonSettings.autoComplete.extraPaths.length > 0 ? 'true' : 'false',
4646
// Format_Has_Custom_Python_Path: pythonSettings.pythonPath.length !== 'python'.length ? 'true' : 'false',
@@ -149,42 +149,39 @@ export function activate(context: vscode.ExtensionContext) {
149149
context.subscriptions.push(activateSingleFileDebug());
150150
}
151151

152-
// this method is called when your extension is deactivated
153-
export function deactivate() {
154-
}
155-
class PythonExt {
152+
class PythonExt implements vscode.Disposable {
156153

157-
private _isDjangoProject: ContextKey;
154+
private isDjangoProject: ContextKey;
158155

159156
constructor() {
160-
this._isDjangoProject = new ContextKey('python.isDjangoProject');
161-
this._ensureState();
157+
this.isDjangoProject = new ContextKey('python.isDjangoProject');
158+
this.ensureState();
162159
}
163-
164-
private _ensureState(): void {
160+
public dispose() {
161+
this.isDjangoProject = null;
162+
}
163+
private ensureState(): void {
165164
// context: python.isDjangoProject
166165
if (typeof vscode.workspace.rootPath === 'string') {
167-
this._isDjangoProject.set(fs.existsSync(vscode.workspace.rootPath.concat("/manage.py")));
166+
this.isDjangoProject.set(fs.existsSync(vscode.workspace.rootPath.concat("/manage.py")));
168167
}
169168
else {
170-
this._isDjangoProject.set(false);
169+
this.isDjangoProject.set(false);
171170
}
172171
}
173172
}
174173

175174
class ContextKey {
176-
private _name: string;
177-
private _lastValue: boolean;
175+
private lastValue: boolean;
178176

179-
constructor(name: string) {
180-
this._name = name;
177+
constructor(private name: string) {
181178
}
182179

183180
public set(value: boolean): void {
184-
if (this._lastValue === value) {
181+
if (this.lastValue === value) {
185182
return;
186183
}
187-
this._lastValue = value;
188-
vscode.commands.executeCommand('setContext', this._name, this._lastValue);
184+
this.lastValue = value;
185+
vscode.commands.executeCommand('setContext', this.name, this.lastValue);
189186
}
190187
}

src/client/jupyter/common/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
export const PythonLanguage = { language: 'python', scheme: 'file' };
2+
export const PythonLanguage = { language: 'python' };
33

44
export namespace Commands {
55
export namespace Jupyter {

0 commit comments

Comments
 (0)