Skip to content

vscode.executeCodeLensProvider sometimes only contains the range and not title/commands #79805

Closed
@DanTup

Description

@DanTup

I've started seeing intermittent failures in some of my code-lens tests like "command doesn't exist on undefined".

I added some debug logging, and have discovered that sometimes the results from vscode.executeCodeLensProvider contain only a range and no other confirmation.

Here's what my test code looks like:

const cls = await (vs.commands.executeCommand("vscode.executeCodeLensProvider", document.uri, 50) as Thenable<vs.CodeLens[]>);

// TEMP DEBUG
for (const cl of cls) {
	if (!cl.command) {
		throw new Error(`Got code lens without a command! ${JSON.stringify(cl)}`);
	}
}

And it's printing this sometimes:

Error: Got code lens without a command! {"range":[{"line":3,"character":2},{"line":18,"character":4}]}

The ranges match up with what I expect from the provider (and I get the expected count), but there's no way my provider can return ranges without commands - the code looks like this:

return [
	new CodeLens(
		toRange(document, test.offset, test.length),
		{
			arguments: [test],
			command: "_dart.startWithoutDebuggingTestFromOutline",
			title: "Run",
		},
	),
	new CodeLens(
		toRange(document, test.offset, test.length),
		{
			arguments: [test],
			command: "_dart.startDebuggingTestFromOutline",
			title: "Debug",
		},
	),
].concat(runTestTemplates.map((t) => new CodeLens(
	toRange(document, test.offset, test.length),
	{
		arguments: [test, t],
		command: t.template === "run-test" ? "_dart.startWithoutDebuggingTestFromOutline" : "_dart.startDebuggingTestFromOutline",
		title: t.name,
	},
)));

It's not consistent - these results show it failed for 1 of 4 tests on macOS, but passed on Windows and Linux:

Screenshot 2019-08-26 at 12 02 16 pm

I've run the tests repeatedly locally but cannot reproduce (it's on Travis where I see it mostly). It feels like a race condition, but I can't figure out why. I don't use resolve, but I tried passing 50 for the number of items to resolve, but it hasn't helped.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugextensionsIssues concerning extensionsverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions