microsoft / microsoft/monaco-editor
[Bug] Can't use '$' and '.' as triggerCharacters in JSON Language
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?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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