-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
adding colors to dynamically added tokens #1220
Comments
@reddys11 I am not sure what you mean. Can you add some code sample showing the problem? A screenshot might also help. |
This my code for getting colors.. monaco.languages.setMonarchTokensProvider('RuleIT', {
ignoreCase: true,
ApplicationConstants: APPlConstants,
StateVariables: StateVariables,
InputVariables: IPVariables,
RuleVariables: RuleVariables,
Rules: rulesList,
ConditionBlocks: ['IF ALL THIS IS TRUE', 'IF ANY OF THIS IS TRUE', 'IF NONE OF THIS IS TRUE', 'THEN', 'OTHERWISE', 'ALL THIS IS TRUE', 'NONE OF THIS IS TRUE', 'ANY OF THIS IS TRUE'],
tokenizer: {
root: [
[/[A-Za-z0-9_$][\w$ ()-]*\b/, {
cases: {
'@ApplicationConstants': 'ApplicationConstants',
'@StateVariables': 'StateVariables',
'@InputVariables': 'InputVariables',
'@ConditionBlocks': 'ConditionBlocks',
'@RuleVariables': 'RuleVariables',
'@Rules': 'Rules'
}
}],
[/^\s*\/.*/, 'comment']
]
}
});
monaco.editor.defineTheme('RuleTheme', {
base: 'vs',
inherit: false,
rules: [{
token: 'ApplicationConstants',
foreground: '6680cc',
fontStyle: 'bold'
},
{
token: 'StateVariables',
foreground: '0000FF',
fontStyle: 'bold italic'
},
{
token: 'InputVariables',
foreground: '0000FF',
fontStyle: 'bold'
},
{
token: 'RuleVariables',
foreground: '0000FF'
},
{
token: 'ConditionBlocks',
foreground: '0079AD',
fontStyle: 'bold'
},
{
token: 'Rules',
foreground: 'C80000',
fontStyle: ''
},
{
token: 'comment',
foreground: '006100',
fontStyle: 'bold'
}
]
}); when i load the editor instance i am getting colors for the variables by the above code. but when i tried try to create new variables and pushing it to the same array ,i am unable to get color for that variable. |
Are you modifying the language definition data structure after you have called var foo = { ... };
monaco.languages.setMonarchTokensProvider(..., foo);
foo.bar.push(`baz`); you should set the language grammar again if you are modifying it: var foo = { ... };
monaco.languages.setMonarchTokensProvider(..., foo);
foo.bar.push(`baz`);
monaco.languages.setMonarchTokensProvider(..., foo); |
for the first time all the tokens are getting color when the editor is loaded but when the user added new tokens dynamically then color is not applying to the recently created tokens,how can i update the tokens. can anyone help on this issue.
The text was updated successfully, but these errors were encountered: