@codemirror/lint 0.19.5 → 0.20.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 +18 -0
- package/dist/index.cjs +18 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -9
- package/package.json +3 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## 0.20.1 (2022-04-22)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Hide lint tooltips when the document is changed.
|
|
6
|
+
|
|
7
|
+
## 0.20.0 (2022-04-20)
|
|
8
|
+
|
|
9
|
+
### Breaking changes
|
|
10
|
+
|
|
11
|
+
Update dependencies to 0.20.0
|
|
12
|
+
|
|
13
|
+
## 0.19.6 (2022-03-04)
|
|
14
|
+
|
|
15
|
+
### Bug fixes
|
|
16
|
+
|
|
17
|
+
Fix a bug where hovering over the icons in the lint gutter would sometimes fail to show a tooltip or show the tooltip for another line.
|
|
18
|
+
|
|
1
19
|
## 0.19.5 (2022-02-25)
|
|
2
20
|
|
|
3
21
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -4,10 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var view = require('@codemirror/view');
|
|
6
6
|
var state = require('@codemirror/state');
|
|
7
|
-
var tooltip = require('@codemirror/tooltip');
|
|
8
|
-
var panel = require('@codemirror/panel');
|
|
9
|
-
var gutter = require('@codemirror/gutter');
|
|
10
|
-
var rangeset = require('@codemirror/rangeset');
|
|
11
7
|
var elt = require('crelt');
|
|
12
8
|
|
|
13
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -53,6 +49,9 @@ function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
|
|
53
49
|
});
|
|
54
50
|
return found;
|
|
55
51
|
}
|
|
52
|
+
function hideTooltip(tr, tooltip) {
|
|
53
|
+
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
|
|
54
|
+
}
|
|
56
55
|
function maybeEnableLint(state$1, effects) {
|
|
57
56
|
return state$1.field(lintState, false) ? effects : effects.concat(state.StateEffect.appendConfig.of([
|
|
58
57
|
lintState,
|
|
@@ -62,7 +61,7 @@ function maybeEnableLint(state$1, effects) {
|
|
|
62
61
|
activeMark.range(selected.from, selected.to)
|
|
63
62
|
]);
|
|
64
63
|
}),
|
|
65
|
-
|
|
64
|
+
view.hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
|
66
65
|
baseTheme
|
|
67
66
|
]));
|
|
68
67
|
}
|
|
@@ -109,7 +108,7 @@ const lintState = state.StateField.define({
|
|
|
109
108
|
}
|
|
110
109
|
return value;
|
|
111
110
|
},
|
|
112
|
-
provide: f => [
|
|
111
|
+
provide: f => [view.showPanel.from(f, val => val.panel),
|
|
113
112
|
view.EditorView.decorations.from(f, s => s.diagnostics)]
|
|
114
113
|
});
|
|
115
114
|
/**
|
|
@@ -148,13 +147,13 @@ function diagnosticsTooltip(view, diagnostics) {
|
|
|
148
147
|
/**
|
|
149
148
|
Command to open and focus the lint panel.
|
|
150
149
|
*/
|
|
151
|
-
const openLintPanel = (view) => {
|
|
152
|
-
let field = view.state.field(lintState, false);
|
|
150
|
+
const openLintPanel = (view$1) => {
|
|
151
|
+
let field = view$1.state.field(lintState, false);
|
|
153
152
|
if (!field || !field.panel)
|
|
154
|
-
view.dispatch({ effects: maybeEnableLint(view.state, [togglePanel.of(true)]) });
|
|
155
|
-
let panel
|
|
156
|
-
if (panel
|
|
157
|
-
panel
|
|
153
|
+
view$1.dispatch({ effects: maybeEnableLint(view$1.state, [togglePanel.of(true)]) });
|
|
154
|
+
let panel = view.getPanel(view$1, LintPanel.open);
|
|
155
|
+
if (panel)
|
|
156
|
+
panel.dom.querySelector(".cm-panel-lint ul").focus();
|
|
158
157
|
return true;
|
|
159
158
|
};
|
|
160
159
|
/**
|
|
@@ -577,7 +576,7 @@ const baseTheme = view.EditorView.baseTheme({
|
|
|
577
576
|
}
|
|
578
577
|
}
|
|
579
578
|
});
|
|
580
|
-
class LintGutterMarker extends
|
|
579
|
+
class LintGutterMarker extends view.GutterMarker {
|
|
581
580
|
constructor(diagnostics) {
|
|
582
581
|
super();
|
|
583
582
|
this.diagnostics = diagnostics;
|
|
@@ -611,7 +610,7 @@ function trackHoverOn(view, marker) {
|
|
|
611
610
|
}
|
|
612
611
|
function gutterMarkerMouseOver(view, marker, diagnostics) {
|
|
613
612
|
function hovered() {
|
|
614
|
-
let line = view.
|
|
613
|
+
let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
|
|
615
614
|
const linePos = view.coordsAtPos(line.from);
|
|
616
615
|
if (linePos) {
|
|
617
616
|
view.dispatch({ effects: setLintGutterTooltip.of({
|
|
@@ -649,15 +648,15 @@ function markersForDiagnostics(doc, diagnostics) {
|
|
|
649
648
|
for (let line in byLine) {
|
|
650
649
|
markers.push(new LintGutterMarker(byLine[line]).range(+line));
|
|
651
650
|
}
|
|
652
|
-
return
|
|
651
|
+
return state.RangeSet.of(markers, true);
|
|
653
652
|
}
|
|
654
|
-
const lintGutterExtension =
|
|
653
|
+
const lintGutterExtension = view.gutter({
|
|
655
654
|
class: "cm-gutter-lint",
|
|
656
655
|
markers: view => view.state.field(lintGutterMarkers),
|
|
657
656
|
});
|
|
658
657
|
const lintGutterMarkers = state.StateField.define({
|
|
659
658
|
create() {
|
|
660
|
-
return
|
|
659
|
+
return state.RangeSet.empty;
|
|
661
660
|
},
|
|
662
661
|
update(markers, tr) {
|
|
663
662
|
markers = markers.map(tr.changes);
|
|
@@ -673,10 +672,10 @@ const lintGutterTooltip = state.StateField.define({
|
|
|
673
672
|
create() { return null; },
|
|
674
673
|
update(tooltip, tr) {
|
|
675
674
|
if (tooltip && tr.docChanged)
|
|
676
|
-
tooltip = Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
|
|
675
|
+
tooltip = hideTooltip(tr, tooltip) ? null : Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
|
|
677
676
|
return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
|
|
678
677
|
},
|
|
679
|
-
provide: field =>
|
|
678
|
+
provide: field => view.showTooltip.from(field)
|
|
680
679
|
});
|
|
681
680
|
const lintGutterTheme = view.EditorView.baseTheme({
|
|
682
681
|
".cm-gutter-lint": {
|
package/dist/index.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ interface Action {
|
|
|
47
47
|
/**
|
|
48
48
|
The function to call when the user activates this action. Is
|
|
49
49
|
given the diagnostic's _current_ position, which may have
|
|
50
|
-
changed since the creation of the diagnostic due to editing.
|
|
50
|
+
changed since the creation of the diagnostic, due to editing.
|
|
51
51
|
*/
|
|
52
52
|
apply: (view: EditorView, from: number, to: number) => void;
|
|
53
53
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { Decoration, EditorView, ViewPlugin, logException, WidgetType } from '@codemirror/view';
|
|
2
|
-
import { StateEffect, StateField, Facet, combineConfig } from '@codemirror/state';
|
|
3
|
-
import { hoverTooltip, showTooltip } from '@codemirror/tooltip';
|
|
4
|
-
import { showPanel, getPanel } from '@codemirror/panel';
|
|
5
|
-
import { gutter, GutterMarker } from '@codemirror/gutter';
|
|
6
|
-
import { RangeSet } from '@codemirror/rangeset';
|
|
1
|
+
import { Decoration, showPanel, EditorView, ViewPlugin, hoverTooltip, logException, gutter, showTooltip, getPanel, WidgetType, GutterMarker } from '@codemirror/view';
|
|
2
|
+
import { StateEffect, StateField, Facet, RangeSet, combineConfig } from '@codemirror/state';
|
|
7
3
|
import elt from 'crelt';
|
|
8
4
|
|
|
9
5
|
class SelectedDiagnostic {
|
|
@@ -45,6 +41,9 @@ function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
|
|
45
41
|
});
|
|
46
42
|
return found;
|
|
47
43
|
}
|
|
44
|
+
function hideTooltip(tr, tooltip) {
|
|
45
|
+
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
|
|
46
|
+
}
|
|
48
47
|
function maybeEnableLint(state, effects) {
|
|
49
48
|
return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of([
|
|
50
49
|
lintState,
|
|
@@ -54,7 +53,7 @@ function maybeEnableLint(state, effects) {
|
|
|
54
53
|
activeMark.range(selected.from, selected.to)
|
|
55
54
|
]);
|
|
56
55
|
}),
|
|
57
|
-
hoverTooltip(lintTooltip),
|
|
56
|
+
hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
|
58
57
|
baseTheme
|
|
59
58
|
]));
|
|
60
59
|
}
|
|
@@ -603,7 +602,7 @@ function trackHoverOn(view, marker) {
|
|
|
603
602
|
}
|
|
604
603
|
function gutterMarkerMouseOver(view, marker, diagnostics) {
|
|
605
604
|
function hovered() {
|
|
606
|
-
let line = view.
|
|
605
|
+
let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
|
|
607
606
|
const linePos = view.coordsAtPos(line.from);
|
|
608
607
|
if (linePos) {
|
|
609
608
|
view.dispatch({ effects: setLintGutterTooltip.of({
|
|
@@ -665,7 +664,7 @@ const lintGutterTooltip = /*@__PURE__*/StateField.define({
|
|
|
665
664
|
create() { return null; },
|
|
666
665
|
update(tooltip, tr) {
|
|
667
666
|
if (tooltip && tr.docChanged)
|
|
668
|
-
tooltip = Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
|
|
667
|
+
tooltip = hideTooltip(tr, tooltip) ? null : Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
|
|
669
668
|
return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
|
|
670
669
|
},
|
|
671
670
|
provide: field => showTooltip.from(field)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemirror/lint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"description": "Linting support for the CodeMirror code editor",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "cm-runtests",
|
|
@@ -26,12 +26,8 @@
|
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@codemirror/
|
|
30
|
-
"@codemirror/
|
|
31
|
-
"@codemirror/rangeset": "^0.19.1",
|
|
32
|
-
"@codemirror/state": "^0.19.4",
|
|
33
|
-
"@codemirror/tooltip": "^0.19.16",
|
|
34
|
-
"@codemirror/view": "^0.19.22",
|
|
29
|
+
"@codemirror/state": "^0.20.0",
|
|
30
|
+
"@codemirror/view": "^0.20.2",
|
|
35
31
|
"crelt": "^1.0.5"
|
|
36
32
|
},
|
|
37
33
|
"devDependencies": {
|