microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.17k stars 12.38k forks source link

quickinfo on single line comment expands to enclosing expression #46571

Open mahdi-farnia opened 2 years ago

mahdi-farnia commented 2 years ago

TS Template added by @mjbvz

TypeScript Version: 4.5.0-dev.20211025

Search Terms


Issue Type: Bug

  1. Split code into multiple lines
  2. Between chaining functions put single line comment
  3. Hold command (In my case) and now, comment is getting underlined Then if you click on the comment, Application will goes you to defenition and types of the chained function...
Bug-vscode

This bug is not bothering or making bad things happen and etc... but it's a bug anyway... May be help to prevent more bugs

VS Code version: Code 1.61.0 (ee8c7def80afc00dd6e593ef12f37756d8f504ea, 2021-10-07T18:11:58.853Z) OS version: Darwin x64 20.6.0 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz (8 x 2400)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|2, 2, 2| |Memory (System)|8.00GB (0.16GB free)| |Process Argv|--crash-reporter-id 3abd098e-8913-45d9-9e68-58217d58edc2| |Screen Reader|no| |VM|0%|
Extensions (14) Extension|Author (truncated)|Version ---|---|--- htmltagwrap|bra|0.0.7 npm-intellisense|chr|1.4.0 vscode-svgviewer|css|2.0.0 vscode-eslint|dba|2.2.1 es7-react-js-snippets|dsz|3.1.1 gitlens|eam|11.6.1 vscode-npm-script|eg2|0.3.22 prettier-vscode|esb|9.0.0 auto-rename-tag|for|0.1.9 dotenv|mik|1.0.1 vscodeintellicode|Vis|1.2.14 vscode-icons|vsc|11.6.0 vscode-todo-highlight|way|1.0.4 markdown-all-in-one|yzh|3.4.0
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383:30185418 pythonvspyt602:30300191 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492cf:30256860 pythonvspyt639:30300192 pythontb:30283811 pythonvspyt551:30345470 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscorecescf:30358481 pythondataviewer:30285071 pythonvsuse255:30340121 vscod805cf:30301675 pythonvspyt200:30340761 binariesv615:30325510 vsccppwtct:30378365 pythonvssor306:30344512 bridge0708:30335490 pygetstartedt2:30371810 dockerwalkthru:30377721 bridge0723:30353136 pythonrunftest32:30373476 pythonf5test824:30373475 javagetstartedc:30364665 pythonvspyt187:30373474 vsqsis200:30381674 vsaa593cf:30376535 vssld246cf:30379912 ```
mjbvz commented 2 years ago

Please share a minimal code example (as text) that demonstrates this issue

mahdi-farnia commented 2 years ago

Please share a minimal code example (as text) that demonstrates this issue

I'm sorry i does not check github notifs This is an example text:

Promise.resolve()
.then(() => "Sample")
// Hello
.then(console.log)

Just hover on the comment...

mjbvz commented 2 years ago

Here's the relevant quick info trace:

[Trace  - 01:48:22.447] <semantic> Sending request: quickinfo (147). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/san/x.js",
    "line": 3,
    "offset": 11
}
[Trace  - 01:48:22.449] <semantic> Response received: quickinfo (147). Request took 2 ms. Success: true 
Result: {
    "kind": "method",
    "kindModifiers": "declare",
    "start": {
        "line": 1,
        "offset": 1
    },
    "end": {
        "line": 4,
        "offset": 10
    },
    "displayString": "(method) Promise<string>.then<void, never>(onfulfilled?: (value: string) => void | PromiseLike<void>, onrejected?: (reason: any) => PromiseLike<never>): Promise<void>",
    "documentation": [
        {
            "text": "Attaches callbacks for the resolution and/or rejection of the Promise.",
            "kind": "text"
        }
    ],
    "tags": [
        {
            "name": "param",
            "text": [
                {
                    "text": "onfulfilled",
                    "kind": "parameterName"
                },
                {
                    "text": " ",
                    "kind": "space"
                },
                {
                    "text": "The callback to execute when the Promise is resolved.",
                    "kind": "text"
                }
            ]
        },
        {
            "name": "param",
            "text": [
                {
                    "text": "onrejected",
                    "kind": "parameterName"
                },
                {
                    "text": " ",
                    "kind": "space"
                },
                {
                    "text": "The callback to execute when the Promise is rejected.",
                    "kind": "text"
                }
            ]
        },
        {
            "name": "returns",
            "text": [
                {
                    "text": "A Promise for the completion of which ever callback is executed.",
                    "kind": "text"
                }
            ]
        }
    ]
}

The request seems to be get incorrectly expanded to the entire expression range here

andrewbranch commented 2 years ago

What's the expected behavior when you hover the comment? No quick info, or this response but bounded to the following then?

mjbvz commented 2 years ago

Probably nothing if you are on the comment itself even though it is part of the larger expression here