Skip to content

Commit d5ddf02

Browse files
rename option
1 parent b7118b8 commit d5ddf02

4 files changed

Lines changed: 8 additions & 10 deletions

File tree

‎packages/lib-common/src/types/HatTokenMap.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export interface HatTokenMap {
1616

1717
export interface HatAllocationOptions {
1818
/**
19-
* Whether to preserve previous hat assignments. Defaults to `true`.
20-
* Set to `false` to initialize an allocation independently of its history.
19+
* Whether to ignore previous hat assignments and allocate from scratch.
20+
* Defaults to `false`. Forced hats still apply when starting fresh.
2121
*/
22-
preserveExistingHats?: boolean;
22+
startFresh?: boolean;
2323
}
2424

2525
export interface TokenHat {

‎packages/lib-engine/src/core/HatAllocator.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ suite("HatAllocator", () => {
7676
assert.ok(map.getToken("blue", "h"), "Normal allocation preserves hats");
7777

7878
await allocator.allocateHats([forcedWorld], {
79-
preserveExistingHats: false,
79+
startFresh: true,
8080
});
8181
assert.deepEqual(snapshot(), expected);
8282
assert.ok(map.getToken("default", "w"), "Forced hats are still applied");

‎packages/lib-engine/src/core/HatAllocator.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ export class HatAllocator {
6060
*
6161
* @param forceTokenHats If supplied, force the allocator to use these hats
6262
* for the given tokens. This is used for the tutorial, and for testing.
63-
* @param options Controls whether to preserve previous hat assignments.
63+
* @param options Controls whether to start fresh without previous hat assignments.
6464
*/
6565
async allocateHats(
6666
forceTokenHats?: TokenHat[],
67-
{ preserveExistingHats = true }: HatAllocationOptions = {},
67+
{ startFresh = false }: HatAllocationOptions = {},
6868
) {
6969
const activeMap = await this.context.getActiveMap();
7070

@@ -80,9 +80,7 @@ export class HatAllocator {
8080
tokenGraphemeSplitter: this.tokenGraphemeSplitter,
8181
enabledHatStyles: this.hats.enabledHatStyles,
8282
forceTokenHats: normalizedForceTokenHats,
83-
oldTokenHats: preserveExistingHats
84-
? activeMap.getStaleTokenHats()
85-
: [],
83+
oldTokenHats: startFresh ? [] : activeMap.getStaleTokenHats(),
8684
hatStability: this.ide.configuration.getOwnConfiguration(
8785
"experimental.hatStability",
8886
),

‎packages/lib-node-common/src/runRecordedTest.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export async function runRecordedTest({
152152
// depend on whether VS Code delivered those events before this point.
153153
await hatTokenMap.allocateHats(
154154
serializedMarksToTokenHats(fixture.initialState.marks, editor),
155-
{ preserveExistingHats: false },
155+
{ startFresh: true },
156156
);
157157

158158
await Promise.all(

0 commit comments

Comments
 (0)