@codemirror/lint 6.8.1 → 6.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.cjs +22 -3
- package/dist/index.js +23 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 6.8.3 (2024-11-21)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix an issue that prevented tooltips in the lint gutter from being displayed.
|
|
6
|
+
|
|
7
|
+
## 6.8.2 (2024-09-24)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Show lint markers for code replaced by a block widget.
|
|
12
|
+
|
|
13
|
+
When multiple linters are installed, start displaying results from ones that return quickly even if others are slow to return.
|
|
14
|
+
|
|
1
15
|
## 6.8.1 (2024-06-19)
|
|
2
16
|
|
|
3
17
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -236,10 +236,9 @@ const lintPlugin = view.ViewPlugin.fromClass(class {
|
|
|
236
236
|
this.set = false;
|
|
237
237
|
let { state } = this.view, { sources } = state.facet(lintConfig);
|
|
238
238
|
if (sources.length)
|
|
239
|
-
|
|
240
|
-
let all = annotations.reduce((a, b) => a.concat(b));
|
|
239
|
+
batchResults(sources.map(s => Promise.resolve(s(this.view))), annotations => {
|
|
241
240
|
if (this.view.state.doc == state.doc)
|
|
242
|
-
this.view.dispatch(setDiagnostics(this.view.state,
|
|
241
|
+
this.view.dispatch(setDiagnostics(this.view.state, annotations.reduce((a, b) => a.concat(b))));
|
|
243
242
|
}, error => { view.logException(this.view.state, error); });
|
|
244
243
|
}
|
|
245
244
|
}
|
|
@@ -264,6 +263,18 @@ const lintPlugin = view.ViewPlugin.fromClass(class {
|
|
|
264
263
|
clearTimeout(this.timeout);
|
|
265
264
|
}
|
|
266
265
|
});
|
|
266
|
+
function batchResults(promises, sink, error) {
|
|
267
|
+
let collected = [], timeout = -1;
|
|
268
|
+
for (let p of promises)
|
|
269
|
+
p.then(value => {
|
|
270
|
+
collected.push(value);
|
|
271
|
+
clearTimeout(timeout);
|
|
272
|
+
if (collected.length == promises.length)
|
|
273
|
+
sink(collected);
|
|
274
|
+
else
|
|
275
|
+
setTimeout(() => sink(collected), 200);
|
|
276
|
+
}, error);
|
|
277
|
+
}
|
|
267
278
|
const lintConfig = state.Facet.define({
|
|
268
279
|
combine(input) {
|
|
269
280
|
return Object.assign({ sources: input.map(i => i.source).filter(x => x != null) }, state.combineConfig(input.map(i => i.config), {
|
|
@@ -669,6 +680,7 @@ function gutterMarkerMouseOver(view, marker, diagnostics) {
|
|
|
669
680
|
view.dispatch({ effects: setLintGutterTooltip.of({
|
|
670
681
|
pos: line.from,
|
|
671
682
|
above: false,
|
|
683
|
+
clip: false,
|
|
672
684
|
create() {
|
|
673
685
|
return {
|
|
674
686
|
dom: diagnosticsTooltip(view, diagnostics),
|
|
@@ -706,6 +718,13 @@ function markersForDiagnostics(doc, diagnostics) {
|
|
|
706
718
|
const lintGutterExtension = view.gutter({
|
|
707
719
|
class: "cm-gutter-lint",
|
|
708
720
|
markers: view => view.state.field(lintGutterMarkers),
|
|
721
|
+
widgetMarker: (view, widget, block) => {
|
|
722
|
+
let diagnostics = [];
|
|
723
|
+
view.state.field(lintGutterMarkers).between(block.from, block.to, (from, to, value) => {
|
|
724
|
+
diagnostics.push(...value.diagnostics);
|
|
725
|
+
});
|
|
726
|
+
return diagnostics.length ? new LintGutterMarker(diagnostics) : null;
|
|
727
|
+
}
|
|
709
728
|
});
|
|
710
729
|
const lintGutterMarkers = state.StateField.define({
|
|
711
730
|
create() {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Decoration, showPanel, EditorView, ViewPlugin,
|
|
1
|
+
import { Decoration, showPanel, EditorView, ViewPlugin, gutter, showTooltip, hoverTooltip, getPanel, logException, WidgetType, GutterMarker } from '@codemirror/view';
|
|
2
2
|
import { StateEffect, StateField, Facet, combineConfig, RangeSet } from '@codemirror/state';
|
|
3
3
|
import elt from 'crelt';
|
|
4
4
|
|
|
@@ -234,10 +234,9 @@ const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
234
234
|
this.set = false;
|
|
235
235
|
let { state } = this.view, { sources } = state.facet(lintConfig);
|
|
236
236
|
if (sources.length)
|
|
237
|
-
|
|
238
|
-
let all = annotations.reduce((a, b) => a.concat(b));
|
|
237
|
+
batchResults(sources.map(s => Promise.resolve(s(this.view))), annotations => {
|
|
239
238
|
if (this.view.state.doc == state.doc)
|
|
240
|
-
this.view.dispatch(setDiagnostics(this.view.state,
|
|
239
|
+
this.view.dispatch(setDiagnostics(this.view.state, annotations.reduce((a, b) => a.concat(b))));
|
|
241
240
|
}, error => { logException(this.view.state, error); });
|
|
242
241
|
}
|
|
243
242
|
}
|
|
@@ -262,6 +261,18 @@ const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
262
261
|
clearTimeout(this.timeout);
|
|
263
262
|
}
|
|
264
263
|
});
|
|
264
|
+
function batchResults(promises, sink, error) {
|
|
265
|
+
let collected = [], timeout = -1;
|
|
266
|
+
for (let p of promises)
|
|
267
|
+
p.then(value => {
|
|
268
|
+
collected.push(value);
|
|
269
|
+
clearTimeout(timeout);
|
|
270
|
+
if (collected.length == promises.length)
|
|
271
|
+
sink(collected);
|
|
272
|
+
else
|
|
273
|
+
setTimeout(() => sink(collected), 200);
|
|
274
|
+
}, error);
|
|
275
|
+
}
|
|
265
276
|
const lintConfig = /*@__PURE__*/Facet.define({
|
|
266
277
|
combine(input) {
|
|
267
278
|
return Object.assign({ sources: input.map(i => i.source).filter(x => x != null) }, combineConfig(input.map(i => i.config), {
|
|
@@ -667,6 +678,7 @@ function gutterMarkerMouseOver(view, marker, diagnostics) {
|
|
|
667
678
|
view.dispatch({ effects: setLintGutterTooltip.of({
|
|
668
679
|
pos: line.from,
|
|
669
680
|
above: false,
|
|
681
|
+
clip: false,
|
|
670
682
|
create() {
|
|
671
683
|
return {
|
|
672
684
|
dom: diagnosticsTooltip(view, diagnostics),
|
|
@@ -704,6 +716,13 @@ function markersForDiagnostics(doc, diagnostics) {
|
|
|
704
716
|
const lintGutterExtension = /*@__PURE__*/gutter({
|
|
705
717
|
class: "cm-gutter-lint",
|
|
706
718
|
markers: view => view.state.field(lintGutterMarkers),
|
|
719
|
+
widgetMarker: (view, widget, block) => {
|
|
720
|
+
let diagnostics = [];
|
|
721
|
+
view.state.field(lintGutterMarkers).between(block.from, block.to, (from, to, value) => {
|
|
722
|
+
diagnostics.push(...value.diagnostics);
|
|
723
|
+
});
|
|
724
|
+
return diagnostics.length ? new LintGutterMarker(diagnostics) : null;
|
|
725
|
+
}
|
|
707
726
|
});
|
|
708
727
|
const lintGutterMarkers = /*@__PURE__*/StateField.define({
|
|
709
728
|
create() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemirror/lint",
|
|
3
|
-
"version": "6.8.
|
|
3
|
+
"version": "6.8.3",
|
|
4
4
|
"description": "Linting support for the CodeMirror code editor",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "cm-runtests",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@codemirror/state": "^6.0.0",
|
|
30
|
-
"@codemirror/view": "^6.
|
|
30
|
+
"@codemirror/view": "^6.35.0",
|
|
31
31
|
"crelt": "^1.0.5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|