microsoft / microsoft/monaco-editor

[Bug] editor.action.selectToBracket - selectBrackets argument is not considered

Open
#4,022 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug editor-core help wanted
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.39.0#XQAAAAIyAgAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw0pzbeVciAKctgAboa7BDe5w81D0NzWWcrRMcpvivy8dxflGgeKGGN0QXI3M-x42qF2vF5Z-o_2911jbrUcIPciP6j2NpZmpiPjzgiMIFP4hdTsEHWIO2wJhOSbzII2EM7pJch-d7JY_oYAi-iYRaxb0K6fKs4qqUqLZxqKE3G3-ijXOdhfYB3gfkJJT2ADIjrf3vdTq7mXpcj3DHznsuJU-5trMwvGBS6PmnnV5m44Qa9APOlpLLv-Z0ukCxOeI10S8nYJbx561N8mvHIaikowN5p6943RZ-Tof8Fu_VqAb1RzcfmY22b9XwYfgtRVKOtg-GOAFx913j1scIWnrO6NQbB_eeeTv0pl2BzFVDtDg-DwQh5sDD9wcaaX12eLrqlbMsmQm9IETwGkjW0YkA95Es0b69f1LRl68ZPG6iubDqpXvZQ08N_-qTVEE

Monaco Editor Playground Code
const value = `{
	"name": "john",
	"orgDetails": {
		"name": "xyz",
		"location": "UK"
	},
	"array": ["a", "b", "c", ["d", "e"], "f"]
}`;

const container = document.getElementById("container");
const myEditor = monaco.editor.create(container, {
	value,
	language: "json",
	automaticLayout: true,
});

container.addEventListener('dblclick', () => {
	const actionId = 'editor.action.selectToBracket',
		args = { selectBrackets: false}
	myEditor.trigger(null, actionId, JSON.stringify(args));
});
Reproduction Steps

Double-click anywhere inside the brackets, you will see that the brackets are also included in the selection.

Actual (Problematic) Behavior

Upon double-clicking, the brackets are also included in the selection. Somehow the argument is not working properly.

Expected Behavior

Since we are passing the argument selectBrackets as false then the selection should not include the surrounding brackets.

Additional Context

I have come across this argument from here: https://github.com/Microsoft/vscode/issues/43371
and the implementation of this from here: https://github.com/microsoft/monaco-editor/blob/d514ddaa8d0ac3a3c11bffe6d3ca1bf9ee822228/test/smoke/smoke.test.js#L101-L105

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 code and the referenced test/smoke/smoke.test.js entry. Reproduce editor.action.selectToBracket with selectBrackets set to false, then compare the selection behavior against the expected result and add or update coverage so the surrounding brackets are excluded.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.