MCPcopy Create free account
hub / github.com/TruthHun/BookStack / updateLinting

Function updateLinting

static/editor.md/lib/codemirror/addon/lint/lint.js:129–162  ·  view source on GitHub ↗
(cm, annotationsNotSorted)

Source from the content-addressed store, hash-verified

127 }
128
129 function updateLinting(cm, annotationsNotSorted) {
130 clearMarks(cm);
131 var state = cm.state.lint, options = state.options;
132
133 var annotations = groupByLine(annotationsNotSorted);
134
135 for (var line = 0; line < annotations.length; ++line) {
136 var anns = annotations[line];
137 if (!anns) continue;
138
139 var maxSeverity = null;
140 var tipLabel = state.hasGutter && document.createDocumentFragment();
141
142 for (var i = 0; i < anns.length; ++i) {
143 var ann = anns[i];
144 var severity = ann.severity;
145 if (!severity) severity = "error";
146 maxSeverity = getMaxSeverity(maxSeverity, severity);
147
148 if (options.formatAnnotation) ann = options.formatAnnotation(ann);
149 if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann));
150
151 if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, {
152 className: "CodeMirror-lint-mark-" + severity,
153 __annotation: ann
154 }));
155 }
156
157 if (state.hasGutter)
158 cm.setGutterMarker(line, GUTTER_ID, makeMarker(tipLabel, maxSeverity, anns.length > 1,
159 state.options.tooltips));
160 }
161 if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
162 }
163
164 function onChange(cm) {
165 var state = cm.state.lint;

Callers 1

startLintingFunction · 0.85

Calls 5

groupByLineFunction · 0.85
getMaxSeverityFunction · 0.85
annotationTooltipFunction · 0.85
makeMarkerFunction · 0.85
clearMarksFunction · 0.70

Tested by

no test coverage detected