From 14423134fb16da705d11434e37e1bc41d44e6881 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 13 Jul 2024 10:32:21 +0200 Subject: [PATCH] Remove node process from hat token map --- .../cursorless-engine/src/core/HatTokenMapImpl.ts | 12 +++++------- packages/cursorless-engine/src/util/bigint.ts | 4 ---- 2 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 packages/cursorless-engine/src/util/bigint.ts diff --git a/packages/cursorless-engine/src/core/HatTokenMapImpl.ts b/packages/cursorless-engine/src/core/HatTokenMapImpl.ts index 3be6a51bbf..1b55e646f2 100644 --- a/packages/cursorless-engine/src/core/HatTokenMapImpl.ts +++ b/packages/cursorless-engine/src/core/HatTokenMapImpl.ts @@ -5,9 +5,7 @@ import { ReadOnlyHatMap, TokenHat, } from "@cursorless/common"; -import { hrtime } from "process"; import { ide } from "../singletons/ide.singleton"; -import { abs } from "../util/bigint"; import { Debug } from "./Debug"; import { HatAllocator } from "./HatAllocator"; import { IndividualHatMap } from "./IndividualHatMap"; @@ -16,7 +14,7 @@ import { RangeUpdater } from "./updateSelections/RangeUpdater"; /** * Maximum age for the pre-phrase snapshot before we consider it to be stale */ -const PRE_PHRASE_SNAPSHOT_MAX_AGE_NS = BigInt(6e10); // 60 seconds +const PRE_PHRASE_SNAPSHOT_MAX_AGE_MS = 60000; // 60 seconds /** * Maps from (hatStyle, character) pairs to tokens @@ -34,7 +32,7 @@ export class HatTokenMapImpl implements HatTokenMap { * hat with the same color and shape will refer to the same logical range. */ private prePhraseMapSnapshot?: IndividualHatMap; - private prePhraseMapsSnapshotTimestamp: bigint | null = null; + private prePhraseMapsSnapshotTimestamp: number | null = null; private lastSignalVersion: string | null = null; private hatAllocator: HatAllocator; @@ -106,8 +104,8 @@ export class HatTokenMapImpl implements HatTokenMap { } if ( - abs(hrtime.bigint() - this.prePhraseMapsSnapshotTimestamp!) > - PRE_PHRASE_SNAPSHOT_MAX_AGE_NS + Math.abs(Date.now() - this.prePhraseMapsSnapshotTimestamp!) > + PRE_PHRASE_SNAPSHOT_MAX_AGE_MS ) { console.error( "Navigation map pre-phrase snapshot requested, but snapshot is more than a minute old", @@ -149,6 +147,6 @@ export class HatTokenMapImpl implements HatTokenMap { } this.prePhraseMapSnapshot = this.activeMap.clone(); - this.prePhraseMapsSnapshotTimestamp = hrtime.bigint(); + this.prePhraseMapsSnapshotTimestamp = Date.now(); } } diff --git a/packages/cursorless-engine/src/util/bigint.ts b/packages/cursorless-engine/src/util/bigint.ts deleted file mode 100644 index 712b3742b4..0000000000 --- a/packages/cursorless-engine/src/util/bigint.ts +++ /dev/null @@ -1,4 +0,0 @@ -// From https://stackoverflow.com/a/64953280 -export function abs(x: bigint) { - return x < BigInt(0) ? -x : x; -}