microsoft / microsoft/monaco-editor

[Bug] CodeLens. range.startColumn not take effect

Open
#4,792 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Reproducible in vscode.dev or in VS Code Desktop?
  • Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.52.2#XQAAAAIvAwAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw3BkLADpQaK_EVxFniLUT0SQgPlzliH97pkRAgqY-pGy1EUKJUtY8TRUmTb5Nv2OAWrVMNWWsQvVxkbZkfoWl-YM4vfrpI4r7l8k7D7lPN0a4Q4aHdfER88KoI_exp4n5HqZQIbF5MIgSb-6jSO9yCBnFpkcrmI08zCrS9x-L3WaQoghta4cP66K82e6H_J1EpUVtF-OZ3NFTfpYIBoig-tbvh-1bTLeoQQQlklT8aWpm1BohrZZSBJmjBeTgMdBIgDoempHmohBsyq8Of-OE4W_k2V45Yj_WXf0ElwaXYo2fQilwni0XSSAralyr3PwJ_wtzUXMGx2tbMWQMqWxzWDs0TG6E8enXET_orZn39zcWCP-OwWq5b60aopJlu9RmvGkrI3pSiRBvosz0JweYPb0gkMOekLcX6KnxHtpPwobD8Tq_EL0e25H-hExamsVn3mH-6gMaXT0JGgAt77onz74T-fdu3xP7tKodwDtzBsPRM9I-wC3mOZiN9prradYXcSyGuKg7Mnh3kp5HUDh55fBRfD1X_-ea2R8

Monaco Editor Playground Code
var editor = monaco.editor.create(document.getElementById("container"), {
	value: '{\n\t"dependencies": {\n\t\t\n\t}\n}\n',
	language: "json",
});

var commandId = editor.addCommand(
	0,
	function () {
		// services available in `ctx`
		alert("my command is executing!");
	},
	""
);

monaco.languages.registerCodeLensProvider("json", {
	provideCodeLenses: function (model, token) {
		return {
			lenses: [
				{
					range: {
						startLineNumber: 1,
						startColumn: 10,
						endLineNumber: 1,
						endColumn: 20,
					},
					id: "First Line",
					command: {
						id: commandId,
						title: "First Line",
					},
				},
			],
			dispose: () => {},
		};
	},
	resolveCodeLens: function (model, codeLens, token) {
		return codeLens;
	},
});
Reproduction Steps
  1. open the link
  2. past the code
Actual (Problematic) Behavior

the codelens always displays on the left top of the specified line, the endLineNumber, startColumn and endColumn do not take effect

Expected Behavior

I suppose it should be able to create inline codelens by specifying the startlinlNumber equal to endLineNumber and endColumn as content lens,

Additional Context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Monaco Editor Playground reproduction and its registerCodeLensProvider implementation, especially the supplied range values. Verify how CodeLens placement uses startLineNumber, endLineNumber, startColumn, and endColumn, then run the reproduction to confirm the expected inline placement and add or update coverage for the corrected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.