@lezer/common 1.1.1 → 1.1.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/dist/index.cjs CHANGED
@@ -1938,18 +1938,14 @@ function sliceBuf(buf, startI, endI, nodes, positions, off) {
1938
1938
  // any other code, making violations of the immutability safe.
1939
1939
  function materialize(cursor) {
1940
1940
  let { node } = cursor, stack = [];
1941
+ let buffer = node.context.buffer;
1941
1942
  // Scan up to the nearest tree
1942
1943
  do {
1943
1944
  stack.push(cursor.index);
1944
1945
  cursor.parent();
1945
1946
  } while (!cursor.tree);
1946
1947
  // Find the index of the buffer in that tree
1947
- let i = 0, base = cursor.tree, off = 0;
1948
- for (;; i++) {
1949
- off = base.positions[i] + cursor.from;
1950
- if (off <= node.from && off + base.children[i].length >= node.to)
1951
- break;
1952
- }
1948
+ let base = cursor.tree, i = base.children.indexOf(buffer);
1953
1949
  let buf = base.children[i], b = buf.buffer, newStack = [i];
1954
1950
  // Split a level in the buffer, putting the nodes before and after
1955
1951
  // the child that contains `node` into new buffers.
package/dist/index.js CHANGED
@@ -1936,18 +1936,14 @@ function sliceBuf(buf, startI, endI, nodes, positions, off) {
1936
1936
  // any other code, making violations of the immutability safe.
1937
1937
  function materialize(cursor) {
1938
1938
  let { node } = cursor, stack = [];
1939
+ let buffer = node.context.buffer;
1939
1940
  // Scan up to the nearest tree
1940
1941
  do {
1941
1942
  stack.push(cursor.index);
1942
1943
  cursor.parent();
1943
1944
  } while (!cursor.tree);
1944
1945
  // Find the index of the buffer in that tree
1945
- let i = 0, base = cursor.tree, off = 0;
1946
- for (;; i++) {
1947
- off = base.positions[i] + cursor.from;
1948
- if (off <= node.from && off + base.children[i].length >= node.to)
1949
- break;
1950
- }
1946
+ let base = cursor.tree, i = base.children.indexOf(buffer);
1951
1947
  let buf = base.children[i], b = buf.buffer, newStack = [i];
1952
1948
  // Split a level in the buffer, putting the nodes before and after
1953
1949
  // the child that contains `node` into new buffers.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lezer/common",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Syntax tree data structure and parser interfaces for the lezer parser",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "module",