Skip to content

Commit ca48439

Browse files
committed
fix #425
1 parent fddedda commit ca48439

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,11 @@
776776
"default": [],
777777
"description": "List of paths to libraries and the like that need to be imported by auto complete engine. E.g. when using Google App SDK, the paths are not in system path, hence need to be added into this list."
778778
},
779+
"python.autoComplete.addBrackets": {
780+
"type": "boolean",
781+
"default": false,
782+
"description": "Automatically add brackets for functions."
783+
},
779784
"python.unitTest.promptToConfigure": {
780785
"type": "boolean",
781786
"default": true,

src/client/common/configSettings.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export interface IFormattingSettings {
8080
outputWindow: string;
8181
}
8282
export interface IAutoCompeteSettings {
83+
addBrackets: boolean;
8384
extraPaths: string[];
8485
}
8586
export interface ITerminalSettings {
@@ -194,7 +195,8 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
194195
}
195196
// Support for travis
196197
this.autoComplete = this.autoComplete ? this.autoComplete : {
197-
extraPaths: []
198+
extraPaths: [],
199+
addBrackets: false
198200
};
199201

200202
let unitTestSettings = systemVariables.resolveAny(pythonSettings.get<IUnitTestSettings>('unitTest'));

src/client/providers/completionProvider.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import * as proxy from './jediProxy';
55
import * as telemetryContracts from '../common/telemetryContracts';
66
import { extractSignatureAndDocumentation } from './jediHelpers';
77
import { EOL } from 'os';
8+
import { PythonSettings } from '../common/configSettings';
9+
10+
const pythonSettings = PythonSettings.getInstance();
811

912
export class PythonCompletionItemProvider implements vscode.CompletionItemProvider {
1013
private jediProxyHandler: proxy.JediProxyHandler<proxy.ICompletionResult, vscode.CompletionItem[]>;
@@ -20,6 +23,10 @@ export class PythonCompletionItemProvider implements vscode.CompletionItemProvid
2023
completionItem.kind = item.type;
2124
completionItem.documentation = sigAndDocs[1].length === 0 ? item.description : sigAndDocs[1];
2225
completionItem.detail = sigAndDocs[0].split(EOL).join('');
26+
if (pythonSettings.autoComplete.addBrackets === true &&
27+
(item.kind === vscode.SymbolKind.Function || item.kind === vscode.SymbolKind.Method)) {
28+
completionItem.insertText = item.text + '({{}})';
29+
}
2330

2431
// ensure the built in memebers are at the bottom
2532
completionItem.sortText = (completionItem.label.startsWith('__') ? 'z' : (completionItem.label.startsWith('_') ? 'y' : '__')) + completionItem.label;

0 commit comments

Comments
 (0)