Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Twig language is not tokenized correctly following arbitrary text #4060

Closed
1 of 2 tasks
claylibrarymarket opened this issue Jul 6, 2023 · 0 comments · Fixed by #4063
Closed
1 of 2 tasks

[Bug] Twig language is not tokenized correctly following arbitrary text #4060

claylibrarymarket opened this issue Jul 6, 2023 · 0 comments · Fixed by #4063

Comments

@claylibrarymarket
Copy link
Contributor

claylibrarymarket commented Jul 6, 2023

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#XQAAAAK1AQAAAAAAAABBqQkHQ5NjdNsB--jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws-BJqVKAuo8RmGmaXErfyRZJ0vWOYpCTsNDP_s_DNT3H_TlPKlr4B7-RZlcXRvkRWqcGq2SFRad0lLGMGd_Vs60GQVX2i4lRn1gwe1SnaKylvbf1QywH_5HdOyjP2qZEUMliQnTEW7eRqRI_NplD0MHXxa454CIsLuP3UPVxK3TaJD362c5uHjGVsg4MEmWiWJEhInvTR636LjpSIip9NpN1jjBCpzwlnD7Vcwlio10h7r_KC8y8AHQH9cP-wvFGzg2SJomSs4JSAT7bujjzjcPENGcsLFVgUp1U-ohL-zb75ArHP9K_rupXANH8TDOnMWmFivOEvh7SvU_6ejs3M

Monaco Editor Playground Code

monaco.editor.colorize('{# initializing ... #}', 'twig', {}).finally(() => {
	const value = JSON.stringify({
		incorrect: monaco.editor.tokenize('test {{ var }}', 'twig'),
		correct: monaco.editor.tokenize('{{ var }}', 'twig'),
	}, null, 4);

	const editor = monaco.editor.create(document.getElementById('container'), {
		language: 'json',
		value
	});
});

Reproduction Steps

Attempt to tokenize Twig code with some arbitrary leading text.

Actual (Problematic) Behavior

The Twig code is not tokenized properly.

Expected Behavior

The Twig code should be tokenized properly.

Additional Context

I believe a small change to the last regular expression in tokenizer.root in this file would resolve this issue:

  • /[^<]+/ => /[^<{]+/.
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant