Skip to content

Imports not being added automatically from code completion in part files #4583

Description

@DanTup

There's a test failing and I can repro this locally. Accepting ProcessResult here should auto-import dart:io into the part_wrapper file:

image

The import is never added. The resolved completion includes a "command": "edit.sendWorkspaceEdit":

{
	"id": : 20,
	"jsonrpc": : "2.0",
	"result": : {
		"additionalTextEdits": : [],
		"command": : {
			"arguments": : [
				{
					"edit": : {
						"documentChanges": : [
							{
								"edits": : [
									{
										"newText": : "import 'dart::io';\n\n",
										"range": : {
											"end": : {
												"character": : 0,
												"line": : 0
											},
											"start": : {
												"character": : 0,
												"line": : 0
											}
										}
									}
								],
								"textDocument": : {
									"uri": : "file::///C::/Dev/Test%20Projects/test_failure_import_part/lib/part_wrapper.dart",
									"version": : 1
								}
							}
						]
					}
				}
			],
			"command": : "edit.sendWorkspaceEdit",
			"title": : "Add import"
		},
		"data": : {
			"file": : "C::\\Dev\\Test Projects\\test_failure_import_part\\lib\\part.dart",
			"importUris": : [
				"dart::io"
			],
			"ref": : "dart::io;dart::io/process.dart;ProcessResult;"
		},
		"detail": : "Auto import from 'dart::io'\n\n(int pid, int exitCode, dynamic stdout, dynamic stderr) → ProcessResult",
		"filterText": : "ProcessResult",
		"insertTextFormat": : 2,
		"insertTextMode": : 1,
		"kind": : 4,
		"label": : "ProcessResult(…)",
		"sortText": : "9999509",
		"textEdit": : {
			"newText": : "ProcessResult(${1::pid}, ${2::exitCode}, ${3::stdout}, ${4::stderr})",
			"range": : {
				"end": : {
					"character": : 24,
					"line": : 3
				},
				"start": : {
					"character": : 12,
					"line": : 3
				}
			}
		}
	}
}

However, that command appears to never be called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions