Socket
Socket
Sign inDemoInstall

@codemirror/rangeset

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/rangeset - npm Package Compare versions

Comparing version 0.18.3 to 0.18.4

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 0.18.4 (2021-06-29)
### Bug fixes
Fix an issue that caused `RangeSet.between` to incorrectly ignore ranges entirely at the start of the iterated region.
## 0.18.3 (2021-06-03)

@@ -2,0 +8,0 @@

28

dist/index.js

@@ -62,8 +62,6 @@ import { MapMode } from '@codemirror/state';

get length() { return this.to[this.to.length - 1]; }
// With side == -1, return the first index where to >= pos. When
// side == 1, the first index where from > pos.
findIndex(pos, end, side = end * 1000000000 /* Far */, startAt = 0) {
if (pos <= 0)
return startAt;
let arr = end < 0 ? this.to : this.from;
// Find the index of the given position and side. Use the ranges'
// `from` pos when `end == false`, `to` when `end == true`.
findIndex(pos, side, end, startAt = 0) {
let arr = end ? this.to : this.from;
for (let lo = startAt, hi = arr.length;;) {

@@ -73,3 +71,3 @@ if (lo == hi)

let mid = (lo + hi) >> 1;
let diff = arr[mid] - pos || (end < 0 ? this.value[mid].startSide : this.value[mid].endSide) - side;
let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;
if (mid == lo)

@@ -84,3 +82,3 @@ return diff >= 0 ? lo : hi;

between(offset, from, to, f) {
for (let i = this.findIndex(from, -1), e = this.findIndex(to, 1, undefined, i); i < e; i++)
for (let i = this.findIndex(from, -1000000000 /* Far */, true), e = this.findIndex(to, 1000000000 /* Far */, false, i); i < e; i++)
if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)

@@ -373,3 +371,3 @@ return false;

let build = new RangeSetBuilder();
for (let range of ranges instanceof Range ? [ranges] : sort ? ranges.slice().sort(cmpRange) : ranges)
for (let range of ranges instanceof Range ? [ranges] : sort ? lazySort(ranges) : ranges)
build.add(range.from, range.to, range.value);

@@ -383,2 +381,12 @@ return build.finish();

RangeSet.empty = /*@__PURE__*/new RangeSet([], [], null, -1);
function lazySort(ranges) {
if (ranges.length > 1)
for (let prev = ranges[0], i = 1; i < ranges.length; i++) {
let cur = ranges[i];
if (cmpRange(prev, cur) > 0)
return ranges.slice().sort(cmpRange);
prev = cur;
}
return ranges;
}
RangeSet.empty.nextLayer = RangeSet.empty;

@@ -524,3 +532,3 @@ /**

let rangeIndex = this.chunkIndex == this.layer.chunk.length ? 0
: this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], -1, side);
: this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);
if (!forward || this.rangeIndex < rangeIndex)

@@ -527,0 +535,0 @@ this.rangeIndex = rangeIndex;

{
"name": "@codemirror/rangeset",
"version": "0.18.3",
"version": "0.18.4",
"description": "Range set data structure for the CodeMirror code editor",

@@ -5,0 +5,0 @@ "scripts": {

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