Skip to content

Double suggestions #3555

Closed
Closed

Description

@theSharpestTool

Describe the bug
VSCode shows double suggestions

To Reproduce
Steps to reproduce the behavior:
Try to trigger suggestions for any widget you will see that every options displayed twice. I guess it happened when Dart Code extension was updated to 3.26.0

Expected behavior
Should seee only one option

Screenshots
Screenshot 2021-09-09 at 16 05 38

Versions (please complete the following information):

  • VS Code version: 1.60.0 (Universal) Mac OS
  • Dart extension version: 3.26.0
  • Dart/Flutter SDK version: Flutter 2.5.0, Dart 2.14.0

Activity

  1. theSharpestTool commented on Sep 10, 2021

    @theSharpestTool
    Author

    Was caused by analysis_options.yaml

  2. DanTup commented on Sep 13, 2021

    @DanTup
    Member

    @theSharpestTool can you be more specific? I'd be interested to know what caused this to see if it could be handled better. Thanks!

  3. theSharpestTool commented on Sep 13, 2021

    @theSharpestTool
    Author

    Hi @DanTup it occurred because I added dart-code-metrics to my project, but first thought was that something wrong with the dart extension. I created the issue on dart-code-metrics you can review it

  4. DanTup commented on Sep 13, 2021

    @DanTup
    Member

    Thanks - I can repro and this looks like a bug in the LSP initialisation, I'm taking a look.

  5. reopened this on Sep 13, 2021
  6. added this to the v3.27.0 milestone on Sep 13, 2021
  7. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Sep 13, 2021
  8. DanTup commented on Sep 13, 2021

    @DanTup
    Member

    This looks like an issue in the LSP initialisation when there are plugins. We register two completion providers:

    {
    	"id": "3",
    	"method": "textDocument/completion",
    	"registerOptions": {
    		"documentSelector": [
    			{
    				"language": "dart",
    				"scheme": "file"
    			}
    		],
    		"triggerCharacters": [
    			".",
    			"=",
    			"(",
    			"$",
    			"\"",
    			"'",
    			"{",
    			"/",
    			":"
    		],
    		"resolveProvider": true
    	}
    },
    {
    	"id": "4",
    	"method": "textDocument/completion",
    	"registerOptions": {
    		"documentSelector": [
    			{
    				"language": "yaml",
    				"scheme": "file",
    				"pattern": "**/pubspec.yaml"
    			},
    			{
    				"language": "yaml",
    				"scheme": "file",
    				"pattern": "**/analysis_options.yaml"
    			},
    			{
    				"language": "yaml",
    				"scheme": "file",
    				"pattern": "**/lib/fix_data.yaml"
    			}
    		],
    		"resolveProvider": true
    	}
    },
    

    Then when the plugin registers and we need to replace them, we only unregister one of them:

    {
    	"id": "2",
    	"method": "textDocument/didChange"
    },
    // there is no 3!
    {
    	"id": "4",
    	"method": "textDocument/completion"
    },
    {
    	"id": "5",
    	"method": "textDocument/hover"
    },
    

    Then we re-register:

    {
    	"id": "26",
    	"method": "textDocument/completion",
    	"registerOptions": {
    		"documentSelector": [
    			{
    				"scheme": "file",
    				"pattern": "**/*.dart"
    			},
    			{
    				"language": "yaml",
    				"scheme": "file",
    				"pattern": "**/pubspec.yaml"
    			},
    			{
    				"language": "yaml",
    				"scheme": "file",
    				"pattern": "**/analysis_options.yaml"
    			},
    			{
    				"language": "yaml",
    				"scheme": "file",
    				"pattern": "**/lib/fix_data.yaml"
    			}
    		],
    		"resolveProvider": true
    	}
    },
    

    Since registration 3 was not removed, we end up with two Dart registrations, which results in VS Code asking for completions twice and the lists (which are identical) merged.

  9. DanTup commented on Sep 15, 2021

    @DanTup
    Member

    This is fixed in the SDK by dart-lang/sdk@f951279 and will show up in a future SDK release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions