5
5
ReadOnlyHatMap ,
6
6
TokenHat ,
7
7
} from "@cursorless/common" ;
8
- import { hrtime } from "process" ;
9
8
import { ide } from "../singletons/ide.singleton" ;
10
- import { abs } from "../util/bigint" ;
11
9
import { Debug } from "./Debug" ;
12
10
import { HatAllocator } from "./HatAllocator" ;
13
11
import { IndividualHatMap } from "./IndividualHatMap" ;
@@ -16,7 +14,7 @@ import { RangeUpdater } from "./updateSelections/RangeUpdater";
16
14
/**
17
15
* Maximum age for the pre-phrase snapshot before we consider it to be stale
18
16
*/
19
- const PRE_PHRASE_SNAPSHOT_MAX_AGE_NS = BigInt ( 6e10 ) ; // 60 seconds
17
+ const PRE_PHRASE_SNAPSHOT_MAX_AGE_MS = 60000 ; // 60 seconds
20
18
21
19
/**
22
20
* Maps from (hatStyle, character) pairs to tokens
@@ -34,7 +32,7 @@ export class HatTokenMapImpl implements HatTokenMap {
34
32
* hat with the same color and shape will refer to the same logical range.
35
33
*/
36
34
private prePhraseMapSnapshot ?: IndividualHatMap ;
37
- private prePhraseMapsSnapshotTimestamp : bigint | null = null ;
35
+ private prePhraseMapsSnapshotTimestamp : number | null = null ;
38
36
39
37
private lastSignalVersion : string | null = null ;
40
38
private hatAllocator : HatAllocator ;
@@ -106,8 +104,8 @@ export class HatTokenMapImpl implements HatTokenMap {
106
104
}
107
105
108
106
if (
109
- abs ( hrtime . bigint ( ) - this . prePhraseMapsSnapshotTimestamp ! ) >
110
- PRE_PHRASE_SNAPSHOT_MAX_AGE_NS
107
+ performance . now ( ) - this . prePhraseMapsSnapshotTimestamp ! >
108
+ PRE_PHRASE_SNAPSHOT_MAX_AGE_MS
111
109
) {
112
110
console . error (
113
111
"Navigation map pre-phrase snapshot requested, but snapshot is more than a minute old" ,
@@ -149,6 +147,6 @@ export class HatTokenMapImpl implements HatTokenMap {
149
147
}
150
148
151
149
this . prePhraseMapSnapshot = this . activeMap . clone ( ) ;
152
- this . prePhraseMapsSnapshotTimestamp = hrtime . bigint ( ) ;
150
+ this . prePhraseMapsSnapshotTimestamp = performance . now ( ) ;
153
151
}
154
152
}
0 commit comments