Merge pull request #256 from brahma-dev/main

Ensure that adjacent variables are rendered in separate spans.
This commit is contained in:
Anoop M D 2023-10-01 00:19:46 +05:30 committed by GitHub
commit 3c4ef2f2df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -66,8 +66,7 @@ if (!SERVER_RENDERED) {
if (target.nodeName !== 'SPAN' || state.hoverTimeout !== undefined) { if (target.nodeName !== 'SPAN' || state.hoverTimeout !== undefined) {
return; return;
} }
if (!target.classList.contains('cm-variable-valid')) {
if (target.className !== 'cm-variable-valid') {
return; return;
} }

View File

@ -25,10 +25,11 @@ export const defineCodeMirrorBrunoVariablesMode = (variables, mode) => {
stream.eat('}'); stream.eat('}');
let found = pathFoundInVariables(word, variables); let found = pathFoundInVariables(word, variables);
if (found) { if (found) {
return 'variable-valid'; return 'variable-valid random-' + (Math.random() + 1).toString(36).substring(9);
} else { } else {
return 'variable-invalid'; return 'variable-invalid random-' + (Math.random() + 1).toString(36).substring(9);
} }
// Random classname added so adjacent variables are not rendered in the same SPAN by CodeMirror.
} }
word += ch; word += ch;
} }