Skip to content

Commit 32a6e53

Browse files
committed
Merge remote-tracking branch 'upstream/master'
* upstream/master: Fix feedback service (#246) Fix django context initializer (#248) disable generation of tags file upon extension load (#264)
2 parents 92f775f + ca9b428 commit 32a6e53

File tree

4 files changed

+42
-37
lines changed

4 files changed

+42
-37
lines changed

src/client/feedback/feedbackService.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ export class FeedbackService implements Disposable {
2828
constructor(persistentStateFactory: IPersistentStateFactory) {
2929
this.showFeedbackPrompt = persistentStateFactory.createGlobalPersistentState('SHOW_FEEDBACK_PROMPT', true);
3030
this.userResponded = persistentStateFactory.createGlobalPersistentState('RESPONDED_TO_FEEDBACK', false);
31-
if (this.showFeedbackPrompt.value && !this.userResponded.value) {
32-
this.initialize();
33-
}
31+
this.initialize();
3432
}
3533
public dispose() {
3634
this.counters = undefined;
@@ -44,6 +42,9 @@ export class FeedbackService implements Disposable {
4442
// tslint:disable-next-line:no-void-expression
4543
let commandDisable = commands.registerCommand('python.updateFeedbackCounter', (telemetryEventName: string) => this.updateFeedbackCounter(telemetryEventName));
4644
this.disposables.push(commandDisable);
45+
if (!this.showFeedbackPrompt.value || this.userResponded.value) {
46+
return;
47+
}
4748
// tslint:disable-next-line:no-void-expression
4849
commandDisable = workspace.onDidChangeTextDocument(changeEvent => this.handleChangesToTextDocument(changeEvent.document), this, this.disposables);
4950
this.disposables.push(commandDisable);
@@ -60,7 +61,8 @@ export class FeedbackService implements Disposable {
6061
if (!this.canShowPrompt) {
6162
return;
6263
}
63-
this.counters.incrementEditCounter();
64+
// tslint:disable-next-line:no-non-null-assertion
65+
this.counters!.incrementEditCounter();
6466
}
6567
private updateFeedbackCounter(telemetryEventName: string): void {
6668
// Ignore feedback events.
@@ -70,7 +72,8 @@ export class FeedbackService implements Disposable {
7072
if (!this.canShowPrompt) {
7173
return;
7274
}
73-
this.counters.incrementFeatureUsageCounter();
75+
// tslint:disable-next-line:no-non-null-assertion
76+
this.counters!.incrementFeatureUsageCounter();
7477
}
7578
private thresholdHandler() {
7679
if (!this.canShowPrompt) {

src/client/providers/execInTerminalProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class DjangoContextInitializer implements vscode.Disposable {
233233
this.disposables.push(vscode.window.onDidChangeActiveTextEditor(() => this.ensureState()));
234234
}
235235
private getActiveWorkspace(): string | undefined {
236-
if (!Array.isArray(workspace.workspaceFolders || workspace.workspaceFolders.length === 0)) {
236+
if (!Array.isArray(workspace.workspaceFolders) || workspace.workspaceFolders.length === 0) {
237237
return undefined;
238238
}
239239
if (workspace.workspaceFolders.length === 1) {

src/client/workspaceSymbols/main.ts

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import * as vscode from 'vscode';
2-
import { Generator } from './generator';
2+
import { workspace } from 'vscode';
3+
import { Commands, PythonLanguage } from '../common/constants';
4+
import { isNotInstalledError } from '../common/helpers';
35
import { Installer, InstallerResponse, Product } from '../common/installer';
46
import { fsExistsAsync } from '../common/utils';
5-
import { isNotInstalledError } from '../common/helpers';
6-
import { PythonLanguage, Commands } from '../common/constants';
7+
import { Generator } from './generator';
78
import { WorkspaceSymbolProvider } from './provider';
8-
import { workspace } from 'vscode';
99

1010
const MAX_NUMBER_OF_ATTEMPTS_TO_INSTALL_AND_BUILD = 2;
1111

1212
export class WorkspaceSymbols implements vscode.Disposable {
1313
private disposables: vscode.Disposable[];
1414
private generators: Generator[] = [];
1515
private installer: Installer;
16+
// tslint:disable-next-line:no-any
17+
private timeout: any;
1618
constructor(private outputChannel: vscode.OutputChannel) {
1719
this.disposables = [];
1820
this.disposables.push(this.outputChannel);
@@ -21,12 +23,14 @@ export class WorkspaceSymbols implements vscode.Disposable {
2123
this.registerCommands();
2224
this.initializeGenerators();
2325
vscode.languages.registerWorkspaceSymbolProvider(new WorkspaceSymbolProvider(this.generators, this.outputChannel));
24-
this.buildWorkspaceSymbols(true);
2526
this.disposables.push(vscode.workspace.onDidChangeWorkspaceFolders(() => this.initializeGenerators()));
2627
}
28+
public dispose() {
29+
this.disposables.forEach(d => d.dispose());
30+
}
2731
private initializeGenerators() {
2832
while (this.generators.length > 0) {
29-
const generator = this.generators.shift();
33+
const generator = this.generators.shift()!;
3034
generator.dispose();
3135
}
3236

@@ -36,38 +40,36 @@ export class WorkspaceSymbols implements vscode.Disposable {
3640
});
3741
}
3842
}
39-
registerCommands() {
40-
this.disposables.push(vscode.commands.registerCommand(Commands.Build_Workspace_Symbols, (rebuild: boolean = true, token?: vscode.CancellationToken) => {
41-
this.buildWorkspaceSymbols(rebuild, token);
43+
private registerCommands() {
44+
this.disposables.push(vscode.commands.registerCommand(Commands.Build_Workspace_Symbols, async (rebuild: boolean = true, token?: vscode.CancellationToken) => {
45+
const promises = this.buildWorkspaceSymbols(rebuild, token);
46+
return Promise.all(promises);
4247
}));
4348
}
44-
registerOnSaveHandlers() {
49+
private registerOnSaveHandlers() {
4550
this.disposables.push(vscode.workspace.onDidSaveTextDocument(this.onDidSaveTextDocument.bind(this)));
4651
}
47-
onDidSaveTextDocument(textDocument: vscode.TextDocument) {
52+
private onDidSaveTextDocument(textDocument: vscode.TextDocument) {
4853
if (textDocument.languageId === PythonLanguage.language) {
4954
this.rebuildTags();
5055
}
5156
}
52-
private timeout: number;
53-
rebuildTags() {
57+
private rebuildTags() {
5458
if (this.timeout) {
55-
clearTimeout(this.timeout);
59+
clearTimeout(this.timeout!);
5660
this.timeout = null;
5761
}
5862
this.timeout = setTimeout(() => {
5963
this.buildWorkspaceSymbols(true);
6064
}, 5000);
6165
}
62-
dispose() {
63-
this.disposables.forEach(d => d.dispose());
64-
}
65-
async buildWorkspaceSymbols(rebuild: boolean = true, token?: vscode.CancellationToken): Promise<any> {
66+
// tslint:disable-next-line:no-any
67+
private buildWorkspaceSymbols(rebuild: boolean = true, token?: vscode.CancellationToken): Promise<any>[] {
6668
if (token && token.isCancellationRequested) {
67-
return Promise.resolve([]);
69+
return [];
6870
}
6971
if (this.generators.length === 0) {
70-
return Promise.resolve([]);
72+
return [];
7173
}
7274

7375
let promptPromise: Promise<InstallerResponse>;
@@ -77,17 +79,16 @@ export class WorkspaceSymbols implements vscode.Disposable {
7779
return;
7880
}
7981
const exists = await fsExistsAsync(generator.tagFilePath);
80-
// if file doesn't exist, then run the ctag generator
81-
// Or check if required to rebuild
82+
// If file doesn't exist, then run the ctag generator,
83+
// or check if required to rebuild.
8284
if (!rebuild && exists) {
8385
return;
8486
}
85-
for (let counter = 0; counter < MAX_NUMBER_OF_ATTEMPTS_TO_INSTALL_AND_BUILD; counter++) {
87+
for (let counter = 0; counter < MAX_NUMBER_OF_ATTEMPTS_TO_INSTALL_AND_BUILD; counter += 1) {
8688
try {
8789
await generator.generateWorkspaceTags();
8890
return;
89-
}
90-
catch (error) {
91+
} catch (error) {
9192
if (!isNotInstalledError(error)) {
9293
this.outputChannel.show();
9394
return;
@@ -96,13 +97,12 @@ export class WorkspaceSymbols implements vscode.Disposable {
9697
if (!token || token.isCancellationRequested) {
9798
return;
9899
}
99-
// Display prompt once for all workspaces
100+
// Display prompt once for all workspaces.
100101
if (promptPromise) {
101102
promptResponse = await promptPromise;
102103
continue;
103-
}
104-
else {
105-
promptPromise = this.installer.promptToInstall(Product.ctags, workspace.workspaceFolders[0].uri);
104+
} else {
105+
promptPromise = this.installer.promptToInstall(Product.ctags, workspace.workspaceFolders[0]!.uri);
106106
promptResponse = await promptPromise;
107107
}
108108
if (promptResponse !== InstallerResponse.Installed || (!token || token.isCancellationRequested)) {
@@ -112,4 +112,3 @@ export class WorkspaceSymbols implements vscode.Disposable {
112112
});
113113
}
114114
}
115-

tslint.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
],
4545
"completed-docs": false,
4646
"no-backbone-get-set-outside-model": false,
47-
"no-unsafe-any": false
47+
"no-unsafe-any": false,
48+
"underscore-consistent-invocation": false,
49+
"no-void-expression": false,
50+
"no-non-null-assertion": false
4851
}
4952
}

0 commit comments

Comments
 (0)