@codemirror/lint 6.7.0 → 6.8.0
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 +12 -0
- package/dist/index.cjs +8 -4
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +8 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 6.8.0 (2024-05-23)
|
|
2
|
+
|
|
3
|
+
### New features
|
|
4
|
+
|
|
5
|
+
The new `autoPanel` option can be used to make the panel automatically appear when diagnostics are added and close when no diagnostics are left.
|
|
6
|
+
|
|
7
|
+
## 6.7.1 (2024-05-15)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Don't perform an additional superfluous timed lint run after `forceLinting` has been called.
|
|
12
|
+
|
|
1
13
|
## 6.7.0 (2024-04-30)
|
|
2
14
|
|
|
3
15
|
### New features
|
package/dist/index.cjs
CHANGED
|
@@ -82,17 +82,20 @@ const lintState = state.StateField.define({
|
|
|
82
82
|
return new LintState(view.Decoration.none, null, null);
|
|
83
83
|
},
|
|
84
84
|
update(value, tr) {
|
|
85
|
-
if (tr.docChanged) {
|
|
86
|
-
let mapped = value.diagnostics.map(tr.changes), selected = null;
|
|
85
|
+
if (tr.docChanged && value.diagnostics.size) {
|
|
86
|
+
let mapped = value.diagnostics.map(tr.changes), selected = null, panel = value.panel;
|
|
87
87
|
if (value.selected) {
|
|
88
88
|
let selPos = tr.changes.mapPos(value.selected.from, 1);
|
|
89
89
|
selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
if (!mapped.size && panel && tr.state.facet(lintConfig).autoPanel)
|
|
92
|
+
panel = null;
|
|
93
|
+
value = new LintState(mapped, panel, selected);
|
|
92
94
|
}
|
|
93
95
|
for (let effect of tr.effects) {
|
|
94
96
|
if (effect.is(setDiagnosticsEffect)) {
|
|
95
|
-
|
|
97
|
+
let panel = !tr.state.facet(lintConfig).autoPanel ? value.panel : effect.value.length ? LintPanel.open : null;
|
|
98
|
+
value = LintState.init(effect.value, panel, tr.state);
|
|
96
99
|
}
|
|
97
100
|
else if (effect.is(togglePanel)) {
|
|
98
101
|
value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected);
|
|
@@ -225,6 +228,7 @@ const lintPlugin = view.ViewPlugin.fromClass(class {
|
|
|
225
228
|
this.timeout = setTimeout(this.run, delay);
|
|
226
229
|
}
|
|
227
230
|
run() {
|
|
231
|
+
clearTimeout(this.timeout);
|
|
228
232
|
let now = Date.now();
|
|
229
233
|
if (now < this.lintTime - 10) {
|
|
230
234
|
this.timeout = setTimeout(this.run, this.lintTime - now);
|
package/dist/index.d.cts
CHANGED
|
@@ -93,6 +93,12 @@ interface LintConfig {
|
|
|
93
93
|
behavior.
|
|
94
94
|
*/
|
|
95
95
|
hideOn?: (tr: Transaction, from: number, to: number) => boolean | null;
|
|
96
|
+
/**
|
|
97
|
+
When enabled (defaults to off), this will cause the lint panel
|
|
98
|
+
to automatically open when diagnostics are found, and close when
|
|
99
|
+
all diagnostics are resolved or removed.
|
|
100
|
+
*/
|
|
101
|
+
autoPanel?: boolean;
|
|
96
102
|
}
|
|
97
103
|
interface LintGutterConfig {
|
|
98
104
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -93,6 +93,12 @@ interface LintConfig {
|
|
|
93
93
|
behavior.
|
|
94
94
|
*/
|
|
95
95
|
hideOn?: (tr: Transaction, from: number, to: number) => boolean | null;
|
|
96
|
+
/**
|
|
97
|
+
When enabled (defaults to off), this will cause the lint panel
|
|
98
|
+
to automatically open when diagnostics are found, and close when
|
|
99
|
+
all diagnostics are resolved or removed.
|
|
100
|
+
*/
|
|
101
|
+
autoPanel?: boolean;
|
|
96
102
|
}
|
|
97
103
|
interface LintGutterConfig {
|
|
98
104
|
/**
|
package/dist/index.js
CHANGED
|
@@ -80,17 +80,20 @@ const lintState = /*@__PURE__*/StateField.define({
|
|
|
80
80
|
return new LintState(Decoration.none, null, null);
|
|
81
81
|
},
|
|
82
82
|
update(value, tr) {
|
|
83
|
-
if (tr.docChanged) {
|
|
84
|
-
let mapped = value.diagnostics.map(tr.changes), selected = null;
|
|
83
|
+
if (tr.docChanged && value.diagnostics.size) {
|
|
84
|
+
let mapped = value.diagnostics.map(tr.changes), selected = null, panel = value.panel;
|
|
85
85
|
if (value.selected) {
|
|
86
86
|
let selPos = tr.changes.mapPos(value.selected.from, 1);
|
|
87
87
|
selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
if (!mapped.size && panel && tr.state.facet(lintConfig).autoPanel)
|
|
90
|
+
panel = null;
|
|
91
|
+
value = new LintState(mapped, panel, selected);
|
|
90
92
|
}
|
|
91
93
|
for (let effect of tr.effects) {
|
|
92
94
|
if (effect.is(setDiagnosticsEffect)) {
|
|
93
|
-
|
|
95
|
+
let panel = !tr.state.facet(lintConfig).autoPanel ? value.panel : effect.value.length ? LintPanel.open : null;
|
|
96
|
+
value = LintState.init(effect.value, panel, tr.state);
|
|
94
97
|
}
|
|
95
98
|
else if (effect.is(togglePanel)) {
|
|
96
99
|
value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected);
|
|
@@ -223,6 +226,7 @@ const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
223
226
|
this.timeout = setTimeout(this.run, delay);
|
|
224
227
|
}
|
|
225
228
|
run() {
|
|
229
|
+
clearTimeout(this.timeout);
|
|
226
230
|
let now = Date.now();
|
|
227
231
|
if (now < this.lintTime - 10) {
|
|
228
232
|
this.timeout = setTimeout(this.run, this.lintTime - now);
|