Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signatureHelp resets selected index while completing overload #25208

Closed
mjbvz opened this issue Jun 25, 2018 · 4 comments
Closed

signatureHelp resets selected index while completing overload #25208

mjbvz opened this issue Jun 25, 2018 · 4 comments
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jun 25, 2018

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
}
@mhegazy
Copy link
Contributor

mhegazy commented Jun 25, 2018

Partially a duplicate of #19474. the main issue is that we do not have a partial overload resolution system. should get better completions with #25100.

@mhegazy mhegazy added the Duplicate An existing issue was already created label Jun 25, 2018
@mjbvz mjbvz added VS Code Tracked There is a VS Code equivalent to this issue and removed Duplicate An existing issue was already created labels Jun 25, 2018
@mhegazy mhegazy added Suggestion An idea for TypeScript Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. labels Jul 12, 2018
@ghost
Copy link

ghost commented Jul 14, 2018

@DanielRosenwasser How does #25422 affect this?

@DanielRosenwasser
Copy link
Member

As far as I can tell, there'd be no impact.

@mjbvz
Copy link
Contributor Author

mjbvz commented Oct 28, 2020

This example nows seems to be working for me in VS Code (tested with TS 4.0.3 with VS Code 1.51)

@mjbvz mjbvz closed this as completed Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

3 participants