Skip to content

Commit

Permalink
Remove node process from hat token map
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Jul 13, 2024
1 parent 1429190 commit 1442313
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
12 changes: 5 additions & 7 deletions packages/cursorless-engine/src/core/HatTokenMapImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -149,6 +147,6 @@ export class HatTokenMapImpl implements HatTokenMap {
}

this.prePhraseMapSnapshot = this.activeMap.clone();
this.prePhraseMapsSnapshotTimestamp = hrtime.bigint();
this.prePhraseMapsSnapshotTimestamp = Date.now();
}
}
4 changes: 0 additions & 4 deletions packages/cursorless-engine/src/util/bigint.ts

This file was deleted.

0 comments on commit 1442313

Please sign in to comment.