Skip to content

signatureHelp resets selected index while completing overload #25208

Closed
@mjbvz

Description

@mjbvz

From microsoft/vscode#52750

TypeScript Version: 3.0.0-dev.20180623

Search Terms:

Code

declare function foo(name: 'a', param: { x: number }): void;
declare function foo(name: 'b', param: { y: number }): void;
declare function foo(name: string, param: any): void;

foo('a')

After 'a' in the call to foo, type , then {

Expected behavior:
After typing ,, the sig help picks up that we are on the first overload. After typing the {, we still should have the first overload selected

Actual behavior:
After typing the {, we go to the generic string overload. Here are the relevant logs:

[Trace  - 3:19:26 PM] Sending request: change (693). Response expected: no. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/san/b.ts",
    "line": 5,
    "offset": 8,
    "endLine": 5,
    "endOffset": 8,
    "insertString": ","
}
[Trace  - 3:19:26 PM] Sending request: signatureHelp (694). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/san/b.ts",
    "line": 5,
    "offset": 9
}
[Trace  - 3:19:26 PM] Response received: signatureHelp (694). Request took 19 ms. Success: true 
Result: {
    "items": [
        {
            "isVariadic": false,
            "prefixDisplayParts": [
                {
                    "text": "foo",
                    "kind": "functionName"
                },
                {
                    "text": "(",
                    "kind": "punctuation"
                }
            ],
            "suffixDisplayParts": [
                {
                    "text": ")",
                    "kind": "punctuation"
                },
                {
                    "text": ":",
                    "kind": "punctuation"
                },
                {
                    "text": " ",
                    "kind": "space"
                },
                {
                    "text": "void",
                    "kind": "keyword"
                }
            ],
            "separatorDisplayParts": [
                {
                    "text": ",",
                    "kind": "punctuation"
                },
                {
                    "text": " ",
                    "kind": "space"
                }
            ],
            "parameters": [
                {
                    "name": "name",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "name",
                            "kind": "parameterName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "\"a\"",
                            "kind": "stringLiteral"
                        }
                    ],
                    "isOptional": false
                },
                {
                    "name": "param",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "param",
                            "kind": "parameterName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "{",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "x",
                            "kind": "propertyName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "number",
                            "kind": "keyword"
                        },
                        {
                            "text": ";",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "}",
                            "kind": "punctuation"
                        }
                    ],
                    "isOptional": false
                }
            ],
            "documentation": [],
            "tags": []
        },
        {
            "isVariadic": false,
            "prefixDisplayParts": [
                {
                    "text": "foo",
                    "kind": "functionName"
                },
                {
                    "text": "(",
                    "kind": "punctuation"
                }
            ],
            "suffixDisplayParts": [
                {
                    "text": ")",
                    "kind": "punctuation"
                },
                {
                    "text": ":",
                    "kind": "punctuation"
                },
                {
                    "text": " ",
                    "kind": "space"
                },
                {
                    "text": "void",
                    "kind": "keyword"
                }
            ],
            "separatorDisplayParts": [
                {
                    "text": ",",
                    "kind": "punctuation"
                },
                {
                    "text": " ",
                    "kind": "space"
                }
            ],
            "parameters": [
                {
                    "name": "name",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "name",
                            "kind": "parameterName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "\"b\"",
                            "kind": "stringLiteral"
                        }
                    ],
                    "isOptional": false
                },
                {
                    "name": "param",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "param",
                            "kind": "parameterName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "{",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "y",
                            "kind": "propertyName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "number",
                            "kind": "keyword"
                        },
                        {
                            "text": ";",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "}",
                            "kind": "punctuation"
                        }
                    ],
                    "isOptional": false
                }
            ],
            "documentation": [],
            "tags": []
        },
        {
            "isVariadic": false,
            "prefixDisplayParts": [
                {
                    "text": "foo",
                    "kind": "functionName"
                },
                {
                    "text": "(",
                    "kind": "punctuation"
                }
            ],
            "suffixDisplayParts": [
                {
                    "text": ")",
                    "kind": "punctuation"
                },
                {
                    "text": ":",
                    "kind": "punctuation"
                },
                {
                    "text": " ",
                    "kind": "space"
                },
                {
                    "text": "void",
                    "kind": "keyword"
                }
            ],
            "separatorDisplayParts": [
                {
                    "text": ",",
                    "kind": "punctuation"
                },
                {
                    "text": " ",
                    "kind": "space"
                }
            ],
            "parameters": [
                {
                    "name": "name",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "name",
                            "kind": "parameterName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "string",
                            "kind": "keyword"
                        }
                    ],
                    "isOptional": false
                },
                {
                    "name": "param",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "param",
                            "kind": "parameterName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "any",
                            "kind": "keyword"
                        }
                    ],
                    "isOptional": false
                }
            ],
            "documentation": [],
            "tags": []
        }
    ],
    "applicableSpan": {
        "start": {
            "line": 5,
            "offset": 5
        },
        "end": {
            "line": 5,
            "offset": 9
        }
    },
    "selectedItemIndex": 0,
    "argumentIndex": 1,
    "argumentCount": 2
}
[Trace  - 3:19:28 PM] Sending request: change (702). Response expected: no. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/san/b.ts",
    "line": 5,
    "offset": 9,
    "endLine": 5,
    "endOffset": 9,
    "insertString": "{}"
}
[Trace  - 3:19:28 PM] Sending request: signatureHelp (703). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/san/b.ts",
    "line": 5,
    "offset": 10
}
[Trace  - 3:19:28 PM] Response received: signatureHelp (703). Request took 14 ms. Success: true 
Result: {
    "items": [
        {
            "isVariadic": false,
            "prefixDisplayParts": [
                {
                    "text": "foo",
                    "kind": "functionName"
                },
                {
                    "text": "(",
                    "kind": "punctuation"
                }
            ],
            "suffixDisplayParts": [
                {
                    "text": ")",
                    "kind": "punctuation"
                },
                {
                    "text": ":",
                    "kind": "punctuation"
                },
                {
                    "text": " ",
                    "kind": "space"
                },
                {
                    "text": "void",
                    "kind": "keyword"
                }
            ],
            "separatorDisplayParts": [
                {
                    "text": ",",
                    "kind": "punctuation"
                },
                {
                    "text": " ",
                    "kind": "space"
                }
            ],
            "parameters": [
                {
                    "name": "name",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "name",
                            "kind": "parameterName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "\"a\"",
                            "kind": "stringLiteral"
                        }
                    ],
                    "isOptional": false
                },
                {
                    "name": "param",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "param",
                            "kind": "parameterName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "{",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "x",
                            "kind": "propertyName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "number",
                            "kind": "keyword"
                        },
                        {
                            "text": ";",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "}",
                            "kind": "punctuation"
                        }
                    ],
                    "isOptional": false
                }
            ],
            "documentation": [],
            "tags": []
        },
        {
            "isVariadic": false,
            "prefixDisplayParts": [
                {
                    "text": "foo",
                    "kind": "functionName"
                },
                {
                    "text": "(",
                    "kind": "punctuation"
                }
            ],
            "suffixDisplayParts": [
                {
                    "text": ")",
                    "kind": "punctuation"
                },
                {
                    "text": ":",
                    "kind": "punctuation"
                },
                {
                    "text": " ",
                    "kind": "space"
                },
                {
                    "text": "void",
                    "kind": "keyword"
                }
            ],
            "separatorDisplayParts": [
                {
                    "text": ",",
                    "kind": "punctuation"
                },
                {
                    "text": " ",
                    "kind": "space"
                }
            ],
            "parameters": [
                {
                    "name": "name",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "name",
                            "kind": "parameterName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "\"b\"",
                            "kind": "stringLiteral"
                        }
                    ],
                    "isOptional": false
                },
                {
                    "name": "param",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "param",
                            "kind": "parameterName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "{",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "y",
                            "kind": "propertyName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "number",
                            "kind": "keyword"
                        },
                        {
                            "text": ";",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "}",
                            "kind": "punctuation"
                        }
                    ],
                    "isOptional": false
                }
            ],
            "documentation": [],
            "tags": []
        },
        {
            "isVariadic": false,
            "prefixDisplayParts": [
                {
                    "text": "foo",
                    "kind": "functionName"
                },
                {
                    "text": "(",
                    "kind": "punctuation"
                }
            ],
            "suffixDisplayParts": [
                {
                    "text": ")",
                    "kind": "punctuation"
                },
                {
                    "text": ":",
                    "kind": "punctuation"
                },
                {
                    "text": " ",
                    "kind": "space"
                },
                {
                    "text": "void",
                    "kind": "keyword"
                }
            ],
            "separatorDisplayParts": [
                {
                    "text": ",",
                    "kind": "punctuation"
                },
                {
                    "text": " ",
                    "kind": "space"
                }
            ],
            "parameters": [
                {
                    "name": "name",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "name",
                            "kind": "parameterName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "string",
                            "kind": "keyword"
                        }
                    ],
                    "isOptional": false
                },
                {
                    "name": "param",
                    "documentation": [],
                    "displayParts": [
                        {
                            "text": "param",
                            "kind": "parameterName"
                        },
                        {
                            "text": ":",
                            "kind": "punctuation"
                        },
                        {
                            "text": " ",
                            "kind": "space"
                        },
                        {
                            "text": "any",
                            "kind": "keyword"
                        }
                    ],
                    "isOptional": false
                }
            ],
            "documentation": [],
            "tags": []
        }
    ],
    "applicableSpan": {
        "start": {
            "line": 5,
            "offset": 5
        },
        "end": {
            "line": 5,
            "offset": 11
        }
    },
    "selectedItemIndex": 2,
    "argumentIndex": 1,
    "argumentCount": 2
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptVS Code TrackedThere is a VS Code equivalent to this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions