@codemirror/lint 0.20.0 → 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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.20.1 (2022-04-22)
2
+
3
+ ### Bug fixes
4
+
5
+ Hide lint tooltips when the document is changed.
6
+
1
7
  ## 0.20.0 (2022-04-20)
2
8
 
3
9
  ### Breaking changes
package/dist/index.cjs CHANGED
@@ -49,6 +49,9 @@ function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
49
49
  });
50
50
  return found;
51
51
  }
52
+ function hideTooltip(tr, tooltip) {
53
+ return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
54
+ }
52
55
  function maybeEnableLint(state$1, effects) {
53
56
  return state$1.field(lintState, false) ? effects : effects.concat(state.StateEffect.appendConfig.of([
54
57
  lintState,
@@ -58,7 +61,7 @@ function maybeEnableLint(state$1, effects) {
58
61
  activeMark.range(selected.from, selected.to)
59
62
  ]);
60
63
  }),
61
- view.hoverTooltip(lintTooltip),
64
+ view.hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
62
65
  baseTheme
63
66
  ]));
64
67
  }
@@ -669,7 +672,7 @@ const lintGutterTooltip = state.StateField.define({
669
672
  create() { return null; },
670
673
  update(tooltip, tr) {
671
674
  if (tooltip && tr.docChanged)
672
- 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) });
673
676
  return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
674
677
  },
675
678
  provide: field => view.showTooltip.from(field)
package/dist/index.js CHANGED
@@ -41,6 +41,9 @@ function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
41
41
  });
42
42
  return found;
43
43
  }
44
+ function hideTooltip(tr, tooltip) {
45
+ return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
46
+ }
44
47
  function maybeEnableLint(state, effects) {
45
48
  return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of([
46
49
  lintState,
@@ -50,7 +53,7 @@ function maybeEnableLint(state, effects) {
50
53
  activeMark.range(selected.from, selected.to)
51
54
  ]);
52
55
  }),
53
- hoverTooltip(lintTooltip),
56
+ hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
54
57
  baseTheme
55
58
  ]));
56
59
  }
@@ -661,7 +664,7 @@ const lintGutterTooltip = /*@__PURE__*/StateField.define({
661
664
  create() { return null; },
662
665
  update(tooltip, tr) {
663
666
  if (tooltip && tr.docChanged)
664
- 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) });
665
668
  return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
666
669
  },
667
670
  provide: field => showTooltip.from(field)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/lint",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
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": "^0.20.0",
30
- "@codemirror/view": "^0.20.0",
30
+ "@codemirror/view": "^0.20.2",
31
31
  "crelt": "^1.0.5"
32
32
  },
33
33
  "devDependencies": {