Microsoft/monaco-editor

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

Open

#4022 opened on Jun 13, 2023

View on GitHub
 (1 comment) (0 reactions) (0 assignees)JavaScript (14,836 stars) (1,283 forks)batch import
bugeditor-corehelp wanted

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