Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codemirror- linting - Is there a event to trigger linting explictly?

I am designing an application using CodeMirror that comes with toolbar. Because of performance reason, I am not executing the lint to either through async or asynch mode.

I have provided an icon in the toolbar, on clicking this I am doing the parsing and constructing the errors. But I am stuck with how I can update lint error in editor?

Any pointer would be really helpful.

like image 787
Chetan Avatar asked Jul 04 '14 06:07

Chetan


2 Answers

The lint addon adds an "extension" method to all Editor instances called performLint, combine with editor options of lint: { lintOnChange: false }, and then you can invoke the linter by calling mirror.performLint().

If you define your own lint methods ala

CodeMirror.registerHelper('lint', 'mode', (text) => { /* your cool stuff here */ })

that'll get invoked on performLint().

like image 196
Svend Avatar answered Sep 30 '22 07:09

Svend


Have you tried setting the lint value dynamically using the below code?

//enable
editor.setOption("lint",true);

//disable
editor.setOption("lint",false);

You can see a demo here JSFiddle link

like image 25
vjy Avatar answered Sep 30 '22 07:09

vjy