From 629b3ebad86de34d4252b6b9c014ae02bcea1ca6 Mon Sep 17 00:00:00 2001 From: Pokey Rule Date: Fri, 7 Jan 2022 19:24:06 +0000 Subject: [PATCH] Configurable debounce delay --- package.json | 5 +++++ src/core/HatAllocator.ts | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 532fe901e0..e5c69e6253 100644 --- a/package.json +++ b/package.json @@ -115,6 +115,11 @@ "default": true, "description": "Whether to show decorations on vscode start." }, + "cursorless.decorationDebounceDelayMs": { + "type": "number", + "default": 50, + "description": "How quickly to redraw hats in response to scrolling or cursor movement" + }, "cursorless.debug": { "type": "boolean", "default": false, diff --git a/src/core/HatAllocator.ts b/src/core/HatAllocator.ts index 19e7fc46b1..65666251a1 100644 --- a/src/core/HatAllocator.ts +++ b/src/core/HatAllocator.ts @@ -4,8 +4,6 @@ import { Graph } from "../typings/Types"; import { Disposable } from "vscode"; import { IndividualHatMap } from "./IndividualHatMap"; -const DECORATION_DEBOUNCE_DELAY_MS = 40; - interface Context { getActiveMap(): Promise; } @@ -78,10 +76,14 @@ export class HatAllocator { clearTimeout(this.timeoutHandle); } + const decorationDebounceDelayMs = vscode.workspace + .getConfiguration("cursorless") + .get("decorationDebounceDelayMs")!; + this.timeoutHandle = setTimeout(() => { this.addDecorations(); this.timeoutHandle = null; - }, DECORATION_DEBOUNCE_DELAY_MS); + }, decorationDebounceDelayMs); } private toggleDecorations() {