@codemirror/lint 6.1.1 → 6.2.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 +6 -0
- package/dist/index.cjs +6 -2
- package/dist/index.d.ts +7 -1
- package/dist/index.js +6 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -227,7 +227,8 @@ const lintPlugin = view.ViewPlugin.fromClass(class {
|
|
|
227
227
|
}
|
|
228
228
|
update(update) {
|
|
229
229
|
let config = update.state.facet(lintConfig);
|
|
230
|
-
if (update.docChanged || config != update.startState.facet(lintConfig)
|
|
230
|
+
if (update.docChanged || config != update.startState.facet(lintConfig) ||
|
|
231
|
+
config.needsRefresh && config.needsRefresh(update)) {
|
|
231
232
|
this.lintTime = Date.now() + config.delay;
|
|
232
233
|
if (!this.set) {
|
|
233
234
|
this.set = true;
|
|
@@ -250,7 +251,10 @@ const lintConfig = state.Facet.define({
|
|
|
250
251
|
return Object.assign({ sources: input.map(i => i.source) }, state.combineConfig(input.map(i => i.config), {
|
|
251
252
|
delay: 750,
|
|
252
253
|
markerFilter: null,
|
|
253
|
-
tooltipFilter: null
|
|
254
|
+
tooltipFilter: null,
|
|
255
|
+
needsRefresh: null
|
|
256
|
+
}, {
|
|
257
|
+
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
|
|
254
258
|
}));
|
|
255
259
|
},
|
|
256
260
|
enables: lintPlugin
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _codemirror_state from '@codemirror/state';
|
|
2
2
|
import { EditorState, TransactionSpec, Extension } from '@codemirror/state';
|
|
3
|
-
import { EditorView, Command, KeyBinding } from '@codemirror/view';
|
|
3
|
+
import { EditorView, Command, KeyBinding, ViewUpdate } from '@codemirror/view';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
Describes a problem or hint for a piece of code.
|
|
@@ -64,6 +64,12 @@ interface LintConfig {
|
|
|
64
64
|
*/
|
|
65
65
|
delay?: number;
|
|
66
66
|
/**
|
|
67
|
+
Optional predicate that can be used to indicate when diagnostics
|
|
68
|
+
need to be recomputed. Linting is always re-done on document
|
|
69
|
+
changes.
|
|
70
|
+
*/
|
|
71
|
+
needsRefresh?: null | ((update: ViewUpdate) => boolean);
|
|
72
|
+
/**
|
|
67
73
|
Optional filter to determine which diagnostics produce markers
|
|
68
74
|
in the content.
|
|
69
75
|
*/
|
package/dist/index.js
CHANGED
|
@@ -219,7 +219,8 @@ const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
219
219
|
}
|
|
220
220
|
update(update) {
|
|
221
221
|
let config = update.state.facet(lintConfig);
|
|
222
|
-
if (update.docChanged || config != update.startState.facet(lintConfig)
|
|
222
|
+
if (update.docChanged || config != update.startState.facet(lintConfig) ||
|
|
223
|
+
config.needsRefresh && config.needsRefresh(update)) {
|
|
223
224
|
this.lintTime = Date.now() + config.delay;
|
|
224
225
|
if (!this.set) {
|
|
225
226
|
this.set = true;
|
|
@@ -242,7 +243,10 @@ const lintConfig = /*@__PURE__*/Facet.define({
|
|
|
242
243
|
return Object.assign({ sources: input.map(i => i.source) }, combineConfig(input.map(i => i.config), {
|
|
243
244
|
delay: 750,
|
|
244
245
|
markerFilter: null,
|
|
245
|
-
tooltipFilter: null
|
|
246
|
+
tooltipFilter: null,
|
|
247
|
+
needsRefresh: null
|
|
248
|
+
}, {
|
|
249
|
+
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
|
|
246
250
|
}));
|
|
247
251
|
},
|
|
248
252
|
enables: lintPlugin
|