Socket
Socket
Sign inDemoInstall

lezer-tree

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lezer-tree - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1

.tern-port

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## 0.7.1 (2020-01-23)
### Bug fixes
In `applyChanges`, make sure the tree is collapsed all the way to the
nearest non-error node next to the change.
## 0.7.0 (2020-01-20)

@@ -2,0 +9,0 @@

21

dist/tree.js

@@ -353,12 +353,13 @@ "use strict";

function cutAt(tree, pos, side) {
var sub = tree.resolve(pos);
for (var cur = pos;;) {
var sibling = side < 0 ? sub.childBefore(cur) : sub.childAfter(cur);
if (sibling)
return side < 0 ? sibling.end - 1 : sibling.start + 1;
if (!sub.parent)
return side < 0 ? 0 : 1e9;
cur = side < 0 ? sub.start : sub.end;
sub = sub.parent;
}
var found = -1;
tree.iterate({
from: pos,
to: side < 0 ? 0 : tree.length,
enter: function () { return found < 0 ? undefined : false; },
leave: function (type, start, end) {
if (found < 0 && !type.prop(NodeProp.error))
found = side < 0 ? Math.min(pos, end - 1) : Math.max(pos, start + 1);
}
});
return found > -1 ? found : side < 0 ? 0 : tree.length;
}

@@ -365,0 +366,0 @@ var off = 0;

{
"name": "lezer-tree",
"version": "0.7.0",
"version": "0.7.1",
"description": "Syntax tree data structure for the lezer parser",

@@ -5,0 +5,0 @@ "main": "dist/tree.js",

@@ -368,10 +368,13 @@ /// The default maximum length of a `TreeBuffer` node.

function cutAt(tree: Tree, pos: number, side: -1 | 1) {
let sub = tree.resolve(pos)
for (let cur = pos;;) {
let sibling = side < 0 ? sub.childBefore(cur) : sub.childAfter(cur)
if (sibling) return side < 0 ? sibling.end - 1 : sibling.start + 1
if (!sub.parent) return side < 0 ? 0 : 1e9
cur = side < 0 ? sub.start : sub.end
sub = sub.parent!
}
let found = -1
tree.iterate({
from: pos,
to: side < 0 ? 0 : tree.length,
enter() { return found < 0 ? undefined : false },
leave(type, start, end) {
if (found < 0 && !type.prop(NodeProp.error))
found = side < 0 ? Math.min(pos, end - 1) : Math.max(pos, start + 1)
}
})
return found > -1 ? found : side < 0 ? 0 : tree.length
}

@@ -378,0 +381,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc