@codemirror/lint 6.2.0 → 6.2.1
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 +18 -14
- package/dist/index.js +19 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 6.2.1 (2023-04-13)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
The `linter` function now eagerly includes all lint-related extensions, rather than appending them to the configuration as-needed, so that turning off linting by clearing the compartment that contains it works properly.
|
|
6
|
+
|
|
1
7
|
## 6.2.0 (2023-02-27)
|
|
2
8
|
|
|
3
9
|
### New features
|
package/dist/index.cjs
CHANGED
|
@@ -58,17 +58,7 @@ function hideTooltip(tr, tooltip) {
|
|
|
58
58
|
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
|
|
59
59
|
}
|
|
60
60
|
function maybeEnableLint(state$1, effects) {
|
|
61
|
-
return state$1.field(lintState, false) ? effects : effects.concat(state.StateEffect.appendConfig.of(
|
|
62
|
-
lintState,
|
|
63
|
-
view.EditorView.decorations.compute([lintState], state => {
|
|
64
|
-
let { selected, panel } = state.field(lintState);
|
|
65
|
-
return !selected || !panel || selected.from == selected.to ? view.Decoration.none : view.Decoration.set([
|
|
66
|
-
activeMark.range(selected.from, selected.to)
|
|
67
|
-
]);
|
|
68
|
-
}),
|
|
69
|
-
view.hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
|
70
|
-
baseTheme
|
|
71
|
-
]));
|
|
61
|
+
return state$1.field(lintState, false) ? effects : effects.concat(state.StateEffect.appendConfig.of(lintExtensions));
|
|
72
62
|
}
|
|
73
63
|
/**
|
|
74
64
|
Returns a transaction spec which updates the current set of
|
|
@@ -256,8 +246,7 @@ const lintConfig = state.Facet.define({
|
|
|
256
246
|
}, {
|
|
257
247
|
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
|
|
258
248
|
}));
|
|
259
|
-
}
|
|
260
|
-
enables: lintPlugin
|
|
249
|
+
}
|
|
261
250
|
});
|
|
262
251
|
/**
|
|
263
252
|
Given a diagnostic source, this function returns an extension that
|
|
@@ -265,7 +254,11 @@ enables linting with that source. It will be called whenever the
|
|
|
265
254
|
editor is idle (after its content changed).
|
|
266
255
|
*/
|
|
267
256
|
function linter(source, config = {}) {
|
|
268
|
-
return
|
|
257
|
+
return [
|
|
258
|
+
lintConfig.of({ source, config }),
|
|
259
|
+
lintPlugin,
|
|
260
|
+
lintExtensions
|
|
261
|
+
];
|
|
269
262
|
}
|
|
270
263
|
/**
|
|
271
264
|
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the
|
|
@@ -727,6 +720,17 @@ const lintGutterTheme = view.EditorView.baseTheme({
|
|
|
727
720
|
content: svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
|
|
728
721
|
},
|
|
729
722
|
});
|
|
723
|
+
const lintExtensions = [
|
|
724
|
+
lintState,
|
|
725
|
+
view.EditorView.decorations.compute([lintState], state => {
|
|
726
|
+
let { selected, panel } = state.field(lintState);
|
|
727
|
+
return !selected || !panel || selected.from == selected.to ? view.Decoration.none : view.Decoration.set([
|
|
728
|
+
activeMark.range(selected.from, selected.to)
|
|
729
|
+
]);
|
|
730
|
+
}),
|
|
731
|
+
view.hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
|
732
|
+
baseTheme
|
|
733
|
+
];
|
|
730
734
|
const lintGutterConfig = state.Facet.define({
|
|
731
735
|
combine(configs) {
|
|
732
736
|
return state.combineConfig(configs, {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Decoration, showPanel, EditorView, ViewPlugin, logException, gutter, showTooltip, getPanel, WidgetType,
|
|
1
|
+
import { Decoration, showPanel, EditorView, ViewPlugin, logException, gutter, showTooltip, hoverTooltip, getPanel, WidgetType, GutterMarker } from '@codemirror/view';
|
|
2
2
|
import { StateEffect, StateField, Facet, combineConfig, RangeSet } from '@codemirror/state';
|
|
3
3
|
import elt from 'crelt';
|
|
4
4
|
|
|
@@ -50,17 +50,7 @@ function hideTooltip(tr, tooltip) {
|
|
|
50
50
|
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
|
|
51
51
|
}
|
|
52
52
|
function maybeEnableLint(state, effects) {
|
|
53
|
-
return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of(
|
|
54
|
-
lintState,
|
|
55
|
-
EditorView.decorations.compute([lintState], state => {
|
|
56
|
-
let { selected, panel } = state.field(lintState);
|
|
57
|
-
return !selected || !panel || selected.from == selected.to ? Decoration.none : Decoration.set([
|
|
58
|
-
activeMark.range(selected.from, selected.to)
|
|
59
|
-
]);
|
|
60
|
-
}),
|
|
61
|
-
hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
|
62
|
-
baseTheme
|
|
63
|
-
]));
|
|
53
|
+
return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of(lintExtensions));
|
|
64
54
|
}
|
|
65
55
|
/**
|
|
66
56
|
Returns a transaction spec which updates the current set of
|
|
@@ -248,8 +238,7 @@ const lintConfig = /*@__PURE__*/Facet.define({
|
|
|
248
238
|
}, {
|
|
249
239
|
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
|
|
250
240
|
}));
|
|
251
|
-
}
|
|
252
|
-
enables: lintPlugin
|
|
241
|
+
}
|
|
253
242
|
});
|
|
254
243
|
/**
|
|
255
244
|
Given a diagnostic source, this function returns an extension that
|
|
@@ -257,7 +246,11 @@ enables linting with that source. It will be called whenever the
|
|
|
257
246
|
editor is idle (after its content changed).
|
|
258
247
|
*/
|
|
259
248
|
function linter(source, config = {}) {
|
|
260
|
-
return
|
|
249
|
+
return [
|
|
250
|
+
lintConfig.of({ source, config }),
|
|
251
|
+
lintPlugin,
|
|
252
|
+
lintExtensions
|
|
253
|
+
];
|
|
261
254
|
}
|
|
262
255
|
/**
|
|
263
256
|
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the
|
|
@@ -719,6 +712,17 @@ const lintGutterTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
719
712
|
content: /*@__PURE__*/svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
|
|
720
713
|
},
|
|
721
714
|
});
|
|
715
|
+
const lintExtensions = [
|
|
716
|
+
lintState,
|
|
717
|
+
/*@__PURE__*/EditorView.decorations.compute([lintState], state => {
|
|
718
|
+
let { selected, panel } = state.field(lintState);
|
|
719
|
+
return !selected || !panel || selected.from == selected.to ? Decoration.none : Decoration.set([
|
|
720
|
+
activeMark.range(selected.from, selected.to)
|
|
721
|
+
]);
|
|
722
|
+
}),
|
|
723
|
+
/*@__PURE__*/hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
|
724
|
+
baseTheme
|
|
725
|
+
];
|
|
722
726
|
const lintGutterConfig = /*@__PURE__*/Facet.define({
|
|
723
727
|
combine(configs) {
|
|
724
728
|
return combineConfig(configs, {
|