Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@
"default": 100,
"description": "How long in milliseconds to show a pending edit decoration"
},
"cursorless.decorationDebounceDelay": {
"type": "integer",
"default": 175,
"description": "How long in milliseconds to wait to redraw the hats after an action"
},
"cursorless.hatSizeAdjustment": {
"type": "number",
"default": 0,
Expand Down
7 changes: 5 additions & 2 deletions src/core/HatAllocator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as vscode from "vscode";
import { addDecorationsToEditors } from "../util/addDecorationsToEditor";
import { DECORATION_DEBOUNCE_DELAY } from "../core/constants";
import { Graph } from "../typings/Types";
import { Disposable } from "vscode";
import { IndividualHatMap } from "./IndividualHatMap";
Expand Down Expand Up @@ -72,11 +71,15 @@ export class HatAllocator {
clearTimeout(this.timeoutHandle);
}

const decorationDebounceDelay = vscode.workspace
.getConfiguration("cursorless")
.get<number>("decorationDebounceDelay")!;
Comment on lines +74 to +76
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think there's much of a performance impact to reading this one every time the document changes? The proper way to do this would be to set in constructor and then listen for settings changes, but I can't decide whether it's worth the effort. I'll leave it to you to decide whether to do that or just leave this one as is

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already tried I can't even measure the performance difference since the run to run variation is larger.
Looked at performance draw in task manager during full scroll up and down and uses 2-3% no matter if we read this setting or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might actually be that vscode internally caches settings if the file hasn't updated


this.timeoutHandle = setTimeout(() => {
this.addDecorations();

this.timeoutHandle = null;
}, DECORATION_DEBOUNCE_DELAY);
}, decorationDebounceDelay);
}

private toggleDecorations() {
Expand Down
2 changes: 0 additions & 2 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export const SUBWORD_MATCHER = /[A-Z]?[a-z]+|[A-Z]+(?![a-z])|[0-9]+/g;

export const DECORATION_DEBOUNCE_DELAY = 175;

export const HAT_COLORS = [
"default",
"blue",
Expand Down