@codemirror/lint
Advanced tools
Comparing version 6.8.1 to 6.8.2
@@ -0,1 +1,9 @@ | ||
## 6.8.2 (2024-09-24) | ||
### Bug fixes | ||
Show lint markers for code replaced by a block widget. | ||
When multiple linters are installed, start displaying results from ones that return quickly even if others are slow to return. | ||
## 6.8.1 (2024-06-19) | ||
@@ -2,0 +10,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { Decoration, showPanel, EditorView, ViewPlugin, logException, gutter, showTooltip, hoverTooltip, getPanel, WidgetType, GutterMarker } from '@codemirror/view'; | ||
import { Decoration, showPanel, EditorView, ViewPlugin, gutter, showTooltip, hoverTooltip, getPanel, logException, WidgetType, GutterMarker } from '@codemirror/view'; | ||
import { StateEffect, StateField, Facet, combineConfig, RangeSet } from '@codemirror/state'; | ||
@@ -237,6 +237,5 @@ import elt from 'crelt'; | ||
if (sources.length) | ||
Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => { | ||
let all = annotations.reduce((a, b) => a.concat(b)); | ||
batchResults(sources.map(s => Promise.resolve(s(this.view))), annotations => { | ||
if (this.view.state.doc == state.doc) | ||
this.view.dispatch(setDiagnostics(this.view.state, all)); | ||
this.view.dispatch(setDiagnostics(this.view.state, annotations.reduce((a, b) => a.concat(b)))); | ||
}, error => { logException(this.view.state, error); }); | ||
@@ -266,2 +265,14 @@ } | ||
}); | ||
function batchResults(promises, sink, error) { | ||
let collected = [], timeout = -1; | ||
for (let p of promises) | ||
p.then(value => { | ||
collected.push(value); | ||
clearTimeout(timeout); | ||
if (collected.length == promises.length) | ||
sink(collected); | ||
else | ||
setTimeout(() => sink(collected), 200); | ||
}, error); | ||
} | ||
const lintConfig = /*@__PURE__*/Facet.define({ | ||
@@ -709,2 +720,9 @@ combine(input) { | ||
markers: view => view.state.field(lintGutterMarkers), | ||
widgetMarker: (view, widget, block) => { | ||
let diagnostics = []; | ||
view.state.field(lintGutterMarkers).between(block.from, block.to, (from, to, value) => { | ||
diagnostics.push(...value.diagnostics); | ||
}); | ||
return diagnostics.length ? new LintGutterMarker(diagnostics) : null; | ||
} | ||
}); | ||
@@ -711,0 +729,0 @@ const lintGutterMarkers = /*@__PURE__*/StateField.define({ |
{ | ||
"name": "@codemirror/lint", | ||
"version": "6.8.1", | ||
"version": "6.8.2", | ||
"description": "Linting support for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85858
1827