File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,10 +16,10 @@ export interface HatTokenMap {
1616
1717export 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
2525export interface TokenHat {
Original file line number Diff line number Diff 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" ) ;
Original file line number Diff line number Diff 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 ) ,
Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments