Skip to content
Permalink
Browse files

Use 1e9 instead of 2e9 for big integers

Several engines apparently store only 31 bits in smallints
  • Loading branch information...
marijnh committed Mar 7, 2019
1 parent e463c4f commit 4ae2532f28852df25860e2df53b98ce101003d93
Showing with 6 additions and 6 deletions.
  1. +1 −1 rangeset/src/rangeset.ts
  2. +1 −1 view/src/docview.ts
  3. +2 −2 view/src/viewport.ts
  4. +2 −2 view/test/test-heightmap.ts
@@ -580,7 +580,7 @@ function rebalanceChildren<T extends RangeValue>(local: Range<T>[], children: Ra
}
}

const SIDE_A = 1, SIDE_B = 2, FAR = 2e9
const SIDE_A = 1, SIDE_B = 2, FAR = 1e9

class ComparisonSide<T extends RangeValue> {
heap: LocalSet<T>[] = []
@@ -566,7 +566,7 @@ function extendWithRanges(diff: A<ChangedRange>, ranges: number[]): A<ChangedRan
let result: ChangedRange[] = []
for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
let next = dI == diff.length ? null : diff[dI], off = posA - posB
let end = next ? next.fromB : 2e9
let end = next ? next.fromB : 1e9
while (rI < ranges.length && ranges[rI] < end) {
let from = ranges[rI], to = ranges[rI + 1]
let fromB = Math.max(posB, from), toB = Math.min(end, to)
@@ -40,8 +40,8 @@ export class ViewportState {
}

coverEverything() {
this.top = -2e9
this.bottom = 2e9
this.top = -1e9
this.bottom = 1e9
}

getViewport(doc: Text, heightMap: HeightMap, bias: number, scrollTo: number): Viewport {
@@ -201,7 +201,7 @@ describe("HeightMap", () => {
let block2 = map.blockAt(block1.bottom + 1, text, 0, 0)
ist(block2.from, 4); ist(block2.to, 7)
ist(block2.top, block1.bottom); ist(block2.bottom, block1.bottom, ">")
let block3 = map.blockAt(2e9, text, 0, 0)
let block3 = map.blockAt(1e9, text, 0, 0)
ist(block3.from, 16); ist(block3.to, 19)
ist(block3.bottom, map.height)
})
@@ -259,7 +259,7 @@ describe("HeightMap", () => {
let line3 = map.lineAt(15, byP, text, 0, 0)
ist(line3.from, 12); ist(line3.to, 15)
ist(line3.bottom, map.height)
ist(map.lineAt(2e9, byH, text, 0, 0), line3, eqBlock)
ist(map.lineAt(1e9, byH, text, 0, 0), line3, eqBlock)
})

it("finds lines in lines", () => {

0 comments on commit 4ae2532

Please sign in to comment.
You can’t perform that action at this time.