-
Notifications
You must be signed in to change notification settings - Fork 340
Description
Describe the bug
Summary:
When I've defined a generic extension method, I see n duplicate suggestions for this method when I've imported the extension into n files in my project. This is annoying because it increasingly clutters the suggestions list proportionally for extension methods I frequently use.
Given:
- Define a generic extension method such as:
extension LetExtension<T> on T {
R let<R>(R Function(T) op) => op(this);
}in the file let_extension.dart;
-
This extension is imported into n other files in my project;
-
When I trigger completion suggestions in a new file (in which the extension has not yet been imported) on an object, I see n + 1 occurrences of the extension method (see screenshot below).
-
When I trigger completion suggestions in a file in which the extension has already been imported, I see only one occurrence as expected.
To Reproduce
Steps to reproduce the behavior:
- Create a new Dart project and open it in VS Code.
- Create a generic extension method, i.e. the example
T?.let()extension method above, in a file such aslet_extension.dart. (I've tried many parameters, includingT extends Object, and they all seem to have the same effect). - Create a few test files with a test function in each. Import the extension method into each of these files. Use the VS Code extension's suggestion feature to import the extension method, rather than importing the extension manually.
- As each new instance of the extension is imported into a new file, notice that the list of duplicate suggestions of that method grows with the number of files it has already been imported into.
Expected behavior
The analyzer should (I believe?) resolve the duplicate suggestions to the same library/method and reveal only one suggestion from the original library it was either defined in or explicitly exported from.
Screenshots
- When the extension has not yet been imported, there are n occurrences in the suggestions list:
- After the extension has already been imported, there is only one suggestion occurrence as expected:
Please complete the following information:
You can run the Dart: Collect Diagnostic Information command from the VS Code command palette (F1) to easily capture this information or provide it manually.
!!
Workspace Environment
Dart Code extension: 3.97.20240902
Flutter extension: 3.97.20240902 (not activated)
App: Visual Studio Code - Insiders
App Host: desktop
Version: mac 1.93.0-insider
Workspace type: Dart (LSP)
Workspace name: test_completion
Dart (3.5.2): /Users/tom/flutter/flutter/bin/cache/dart-sdk
Flutter (3.24.2): /Users/tom/flutter/flutter (No device)
Output from 'dart info'
/Users/tom/flutter/flutter/bin/cache/dart-sdk/bin/dart info
If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.
General info
- Dart 3.5.2 (stable) (Wed Aug 28 10:01:20 2024 +0000) on "macos_arm64"
- on macos / Version 14.6.1 (Build 23G93)
- locale is en-US
Project info
- sdk constraint: '^3.5.2'
- dependencies:
- dev_dependencies: lints, test
Process info
| Memory | CPU | Elapsed time | Command line |
|---|---|---|---|
| 69 MB | 0.0% | 25:51 | dart devtools --machine --allow-embedding --dtd-uri ws:/DLNv4p7usCx2UpfG |
| 603 MB | 0.0% | 26:18 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.97.20240902 |
| 796 MB | 0.0% | 25:51 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.97.20240902 |
| 83 MB | 0.0% | 26:18 | dart tooling-daemon --machine |
| 81 MB | 0.0% | 25:51 | dart tooling-daemon --machine |
| 113 MB | 3.2% | 25:51 | flutter_tools.snapshot daemon |