Skip to content

Commit c9aeb9f

Browse files
committed
Prevent return type hints ending with typing hints from creating completion items
1 parent 7c922b3 commit c9aeb9f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/completionProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class ParamHintCompletionProvider extends CompletionProvider implements C
141141
private getParam(precedingText: string): string | null {
142142
const split = precedingText.split(/[,(*]/);
143143
let param = split.length > 1 ? split[split.length - 1].trim() : precedingText;
144-
return !param || /[!:?/\\{}.+/=)'";@&£%¤|<>$^~¨ -]/.test(param) ? null : param;
144+
return !param || /[!:\]\[?/\\{}.+/=)'";@&£%¤|<>$^~¨ -]/.test(param) ? null : param;
145145
}
146146

147147
private pushEstimationsToItems(typeHints: string[], items: CompletionItem[]) {

test/suite/providers/completionProvider.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ suite('ParamHintCompletionProvider', () => {
137137
assert.strictEqual(actual, null);
138138
});
139139

140+
test("does not provide items for end of function definition with typing hint", async () => {
141+
let actual = await providerResult(provider, "def test(n: int) -> List[str]:");
142+
assert.strictEqual(actual, null);
143+
});
144+
145+
test("does not provide items for end of function definition with typing Dict hint", async () => {
146+
let actual = await providerResult(provider, "def test(n: int) -> Dict[str, str]:");
147+
assert.strictEqual(actual, null);
148+
});
149+
140150
test("does not include * in parameter name", async () => {
141151
let param = "*paramName:";
142152
let actual = await providerResult(provider, param, "\n\nparamName = 12");

0 commit comments

Comments
 (0)