microsoft / microsoft/monaco-editor

[Bug] Can't use '$' and '.' as triggerCharacters in JSON Language

Open
#4,347 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.45.0#XQAAAAL3AwAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw5EwHHzYFHaz32-gyIkvFg9IBdF4D6TxsvTg3aTukZ-SMnu1cti_b_tBcWfemMlzae8XEfpqzzq7p3_bAdim2j1CCEjciMpjylo-Vi_luKU0F8CcEMV2H64EyfakcvAlwdpafvU3hXUU0zimxN7pSnEUjS9kbo6Wkl0sid1i3UVJ-RkPIU15LBE8sciSXKLFoqf5eHLQD3zmHWZoehVpR2aJ31oYV-V31CFR1EBtIG3GSstKFgcllVB6FNvV6ohMg0dLI9TDngbIF2unBRvqPf0zMbsiM-2ezYJiZiWjWnhgY0zjfCtRCUVlAN4X3BR4dh73gq4t8OPLwZktbcsXGehSv4vWl8sCijVXcfQLWkMQYsyE11Dg8JakbhGpxl0NBMPOI3PaQAW8PKjSb5W6aAfrUgLDu_HGB_jq8VreVDCtOwZaZuoPD7SqtlVerdB3TPs29wGMfKfCFtA6IkjoTWhn8XgSkdfI2VYrmdVAINV-dUNMuN_GuJYwotPWxjtpagWN8fckeFuRAT5380jTCPEVebg1FVrldmSRnQmB2y-YH9mAFC7R951cy5kXHjEIhx3cekSM2HknxTqcp3CCMVudw5VFiDUvrsCVHobfIBLEz5hG3bygIM2ulndi1407n0DwzEkNjCG0aq8_YMlDLuZcaQPjpzBPpXL6fPVKV_8rzBMSUjKOoRH8jtzAtf3ST-tBlOw

Monaco Editor Playground Code
// Configures two JSON schemas, with references.

var jsonCode = ["{", '    "p1": "v3",', '    "p2": false', "}"].join("\n");
var modelUri = monaco.Uri.parse("a://b/foo.json"); // a made up unique URI for our model
var model = monaco.editor.createModel(jsonCode, "json", modelUri);

const triggerCharacters = ['.', '$', '', '1', ':'];
monaco.languages.registerCompletionItemProvider('json', {
	triggerCharacters,

	// @ts-ignore
	provideCompletionItems: (model, position) => {
		const wordInfo = model.getWordUntilPosition(position);
		const { word, startColumn, endColumn } = wordInfo;

		const suggestions = [
		{
			label: `${word}${word}`,
			kind: monaco.languages.CompletionItemKind.Variable,
			insertText: `${word}${word}`,
			insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
		},
		];

		return {
			suggestions,
		};
	},
});


monaco.editor.create(document.getElementById("container"), {
	model: model,
});
Reproduction Steps

Entering . or $ .

Actual (Problematic) Behavior

There will be an automatic completion prompt when entering the characters 1 and :, but there will be no prompts when entering the characters $ and .

Expected Behavior

Entering . and $ characters will prompt automatic completion.

Additional Context

i don't know how to fix it

### Tasks

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 and run the provided TypeScript reproduction. Inspect how completion providers handle triggerCharacters, then verify that entering . and $ opens completion prompts while 1 and : continue to do so. Done means the expected prompts appear for all four configured characters.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.