Skip to content

Incorrect auto import added for suggestions where same symbol name is exported from multiple files  #42752

@mjbvz

Description

@mjbvz

Bug Report

From microsoft/vscode#116375

🔎 Search Terms

  • completionEntryDetails
  • completion
  • suggest / suggestions
  • source

🕗 Version & Regression Information

Seen on 4.2.0-20210210 and 4.1.5

💻 Repo

  1. In the VS Code codebase, open this file
  2. Delete the existing import for Disposable
  3. Now for export class ExtensionsLifecycle extends Disposable, trigger suggestions at the end of Disposable
  4. Accept the suggestion for Disposable from web.api:

Screen Shot 2021-02-10 at 6 03 31 PM

🙁 Actual behavior

I expected this to add an import from web.api

🙂 Expected behavior

It actually ends up adding the import from import { Disposable } from 'vs/base/common/lifecycle';

I believe this is because the Disposable from web.api is a re-export of the one from lifecycle

You can also get into the reverse state, where the suggestion for lifecycle ends up adding an import from web.api. Here are the completionEntryDetails from that case:

[Trace  - 01:51:33.997] <semantic> Sending request: completionEntryDetails (110). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/vscode/src/vs/platform/extensionManagement/node/extensionLifecycle.ts",
    "line": 16,
    "offset": 52,
    "entryNames": [
        {
            "name": "Disposable",
            "source": "/Users/matb/projects/vscode/src/vs/base/common/lifecycle"
        }
    ]
}
[Trace  - 01:51:34.82] <semantic> Response received: completionEntryDetails (110). Request took 85 ms. Success: true 
Result: [
    {
![Screen Shot 2021-02-10 at 6 03 31 PM](https://user-images.githubusercontent.com/12821956/107595705-534c3080-6bca-11eb-9510-44151ad711e0.png)
        "name": "Disposable",
        "kindModifiers": "abstract,export",
        "kind": "class",
        "displayParts": [
            {
                "text": "class",
                "kind": "keyword"
            },
            {
                "text": " ",
                "kind": "space"
            },
            {
                "text": "Disposable",
                "kind": "className"
            }
        ],
        "documentation": [],
        "codeActions": [
            {
                "description": "Import 'Disposable' from module \"vs/workbench/workbench.web.api\"",
                "changes": [
                    {
                        "fileName": "/Users/matb/projects/vscode/src/vs/platform/extensionManagement/node/extensionLifecycle.ts",
                        "textChanges": [
                            {
                                "start": {
                                    "line": 15,
                                    "offset": 1
                                },
                                "end": {
                                    "line": 15,
                                    "offset": 1
                                },
                                "newText": "import { Disposable } from 'vs/workbench/workbench.web.api';\n"
                            }
                        ]
                    }
                ]
            }
        ],
        "source": [
            {
                "text": "vs/workbench/workbench.web.api",
                "kind": "text"
            }
        ]
    }
]

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions