javascript - Show line errors in codemirror? - Stack Overflow

I just upgraded CodeMirror to latest and have the following code now breaking: clear previous errors

I just upgraded CodeMirror to latest and have the following code now breaking:

        // clear previous errors from editor window
        for (var i = 0; i < layoutCodeEditor.lineCount(); i++) {
            layoutCodeEditor.clearMarker(i);
            layoutCodeEditor.setLineClass(i, null, null);
        }

        var valid = JSLINT(code);
        var jsLintError = "";
        if (!valid) {
            jsLintError = JSLINT.error_report(JSLINT.data());
            _.chain(JSLINT.errors)pact().each(function(e){
                // show markers in the code edit window against lines with Jslint errors
                layoutCodeEditor.setMarker((+e.line) - 1, "●", "errors");
                layoutCodeEditor.setLineClass(+(e.line) - 1, null, "errorLine");                    
            })
        }

seems like the setMarker/clearMarker and setLineClass functions have been removed. What's their equivalents now?

I just upgraded CodeMirror to latest and have the following code now breaking:

        // clear previous errors from editor window
        for (var i = 0; i < layoutCodeEditor.lineCount(); i++) {
            layoutCodeEditor.clearMarker(i);
            layoutCodeEditor.setLineClass(i, null, null);
        }

        var valid = JSLINT(code);
        var jsLintError = "";
        if (!valid) {
            jsLintError = JSLINT.error_report(JSLINT.data());
            _.chain(JSLINT.errors).pact().each(function(e){
                // show markers in the code edit window against lines with Jslint errors
                layoutCodeEditor.setMarker((+e.line) - 1, "●", "errors");
                layoutCodeEditor.setLineClass(+(e.line) - 1, null, "errorLine");                    
            })
        }

seems like the setMarker/clearMarker and setLineClass functions have been removed. What's their equivalents now?

Share Improve this question asked Dec 22, 2012 at 23:33 George MauerGeorge Mauer 122k140 gold badges396 silver badges630 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

These changes, among many others, are covered in the Upgrading to version 3 page on the CodeMirror site.

The marker functions have changed as a consequence of moving to multiple gutters:

Gutter model

In CodeMirror 2.x, there was a single gutter, and line markers created with setMarker would have to somehow coexist with the line numbers (if present). Version 3 allows you to specify an array of gutters, by class name, use setGutterMarker to add or remove markers in individual gutters, and clear whole gutters with clearGutter. Gutter markers are now specified as DOM nodes, rather than HTML snippets.

The gutters no longer horizontally scrolls along with the content. The fixedGutter option was removed (since it is now the only behavior).

The line class change is more straightforward:

Line CSS classes

The setLineClass method has been replaced by addLineClass and removeLineClass, which allow more modular control over the classes attached to a line.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745362037a4624404.html

相关推荐

  • javascript - Show line errors in codemirror? - Stack Overflow

    I just upgraded CodeMirror to latest and have the following code now breaking: clear previous errors

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信