Skip to content

controlling linting from a button click  #311

@hjangir154

Description

@hjangir154

I have case where I need to update the linting error messages from a button click outside the codeMirror component. Although values are updating it wont show up on the editor until i manually update the text inside the editor by typing.

I tried following

  1. refresh editor using instance
  2. updating value prop: value get's updated but linting wont show up
  3. calling forceRefresh() method on component
{
    "mode": "text/x-hive",
    "indentWithTabs": false,
    "lineWrapping": true,
    "lineNumbers": true,
    "gutters": [
        "CodeMirror-lint-markers"
    ],
    "extraKeys": {
        "Ctrl-Space": "autocomplete",
        "Ctrl-/": "toggleComment"
    },
    "indentUnit": 2,
    "theme": "default",
    "matchBrackets": true,
    "autoCloseBrackets": true,
    "highlightSelectionMatches": true,
    "cursorBlinkRate": 530,
    "lint": {
        "async": true,
        "delay": 1000,
         "getAnnotations" : (text, onComplete, _, editor) => {…}
    },
    "tabSize": 2
}

this is the option object i am passing in,

(text: string, onComplete, _, editor) => {
    if ((text || '').length === 0) {
        return;
    }
    function complete(options: []) {
        console.log("OPTIONS inside", options, suggetions)
        onComplete(options.concat(suggetions));
        editor?.refresh();
    }
    console.log("GetAnnotationCalled", suggetions)
    getSqlLintAnnotationsDebounced(text, language, complete);
}

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions