Module: util/allocateHats/allocateHats
Interfaces
Functions
allocateHats
▸ allocateHats(tokenGraphemeSplitter
, enabledHatStyles
, oldTokenHats
, hatStability
, activeTextEditor
, visibleTextEditors
): TokenHat
[]
Allocates hats to all the visible tokens. Proceeds by ranking tokens according to desirability (how far they are from the cursor), then assigning a hat to each one in turn, deciding whether to keep old hat, steal a hat from another token, or use a freely available hat.
See hat assignment for more info.
Parameters
Name | Type | Description |
---|---|---|
tokenGraphemeSplitter | TokenGraphemeSplitter | Splits tokens into graphemes |
enabledHatStyles | HatStyleMap | A list of all enabled hat styles |
oldTokenHats | readonly TokenHat [] | The previous allocation, so that we can try to maintain hat stability |
hatStability | HatStability | The user setting indicating how to trade off quality vs stability |
activeTextEditor | undefined | TextEditor | Currently active text editor |
visibleTextEditors | readonly TextEditor [] | All visible text editors |
Returns
TokenHat
[]
A hat assignment, which is a list where each entry contains a token and the hat that it will wear