Skip to content

Commit

Permalink
Use 1e9 instead of 2e9 for big integers
Browse files Browse the repository at this point in the history
Several engines apparently store only 31 bits in smallints
  • Loading branch information
marijnh committed Mar 13, 2019
1 parent c94a6e9 commit b5aa501
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/docview.ts
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/viewport.ts
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions test/test-heightmap.ts
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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", () => {
Expand Down

0 comments on commit b5aa501

Please sign in to comment.