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

Double suggestions #3555

Closed
theSharpestTool opened this issue Sep 9, 2021 · 6 comments
Closed

Double suggestions #3555

theSharpestTool opened this issue Sep 9, 2021 · 6 comments
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is bug
Milestone

Comments

@theSharpestTool
Copy link

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
@theSharpestTool
Copy link
Author

Was caused by analysis_options.yaml

@DanTup
Copy link
Member

DanTup commented Sep 13, 2021

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

@theSharpestTool
Copy link
Author

theSharpestTool commented Sep 13, 2021

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

@DanTup
Copy link
Member

DanTup commented Sep 13, 2021

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

@DanTup DanTup reopened this Sep 13, 2021
@DanTup DanTup added this to the v3.27.0 milestone Sep 13, 2021
@DanTup DanTup added in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server labels Sep 13, 2021
@DanTup
Copy link
Member

DanTup commented Sep 13, 2021

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.

dart-bot pushed a commit to dart-lang/sdk that referenced this issue Sep 13, 2021
…Dart

... when using plugins that register for Dart files.

Fixes Dart-Code/Dart-Code#3555.

Change-Id: Idadcda0b04f86eb40d11a69e8eadc7120c873ae7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213266
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
@DanTup
Copy link
Member

DanTup commented Sep 15, 2021

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
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is bug
Projects
None yet
Development

No branches or pull requests

2 participants