@codemirror/language 6.3.1 → 6.3.2

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
+ ## 6.3.2 (2022-12-16)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a bug that caused `ensureSyntaxTree` to return incomplete trees when using a viewport-aware parser like `StreamLanguage`.
6
+
1
7
  ## 6.3.1 (2022-11-14)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -183,7 +183,13 @@ up to that point if the tree isn't already available.
183
183
  function ensureSyntaxTree(state, upto, timeout = 50) {
184
184
  var _a;
185
185
  let parse = (_a = state.field(Language.state, false)) === null || _a === void 0 ? void 0 : _a.context;
186
- return !parse ? null : parse.isDone(upto) || parse.work(timeout, upto) ? parse.tree : null;
186
+ if (!parse)
187
+ return null;
188
+ let oldVieport = parse.viewport;
189
+ parse.updateViewport({ from: 0, to: upto });
190
+ let result = parse.isDone(upto) || parse.work(timeout, upto) ? parse.tree : null;
191
+ parse.updateViewport(oldVieport);
192
+ return result;
187
193
  }
188
194
  /**
189
195
  Queries whether there is a full syntax tree available up to the
@@ -1682,7 +1688,7 @@ A default highlight style (works well with light themes).
1682
1688
  */
1683
1689
  const defaultHighlightStyle = HighlightStyle.define([
1684
1690
  { tag: highlight.tags.meta,
1685
- color: "#7a757a" },
1691
+ color: "#404740" },
1686
1692
  { tag: highlight.tags.link,
1687
1693
  textDecoration: "underline" },
1688
1694
  { tag: highlight.tags.heading,
package/dist/index.js CHANGED
@@ -179,7 +179,13 @@ up to that point if the tree isn't already available.
179
179
  function ensureSyntaxTree(state, upto, timeout = 50) {
180
180
  var _a;
181
181
  let parse = (_a = state.field(Language.state, false)) === null || _a === void 0 ? void 0 : _a.context;
182
- return !parse ? null : parse.isDone(upto) || parse.work(timeout, upto) ? parse.tree : null;
182
+ if (!parse)
183
+ return null;
184
+ let oldVieport = parse.viewport;
185
+ parse.updateViewport({ from: 0, to: upto });
186
+ let result = parse.isDone(upto) || parse.work(timeout, upto) ? parse.tree : null;
187
+ parse.updateViewport(oldVieport);
188
+ return result;
183
189
  }
184
190
  /**
185
191
  Queries whether there is a full syntax tree available up to the
@@ -1678,7 +1684,7 @@ A default highlight style (works well with light themes).
1678
1684
  */
1679
1685
  const defaultHighlightStyle = /*@__PURE__*/HighlightStyle.define([
1680
1686
  { tag: tags.meta,
1681
- color: "#7a757a" },
1687
+ color: "#404740" },
1682
1688
  { tag: tags.link,
1683
1689
  textDecoration: "underline" },
1684
1690
  { tag: tags.heading,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/language",
3
- "version": "6.3.1",
3
+ "version": "6.3.2",
4
4
  "description": "Language support infrastructure for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",