()
| 173 | } |
| 174 | |
| 175 | private constructHatStyleMap() { |
| 176 | const shapeEnablement = vscode.workspace |
| 177 | .getConfiguration("cursorless.hatEnablement") |
| 178 | .get<Record<HatShape, boolean>>("shapes")!; |
| 179 | const colorEnablement = vscode.workspace |
| 180 | .getConfiguration("cursorless.hatEnablement") |
| 181 | .get<Record<HatColor, boolean>>("colors")!; |
| 182 | const shapePenalties = vscode.workspace |
| 183 | .getConfiguration("cursorless.hatPenalties") |
| 184 | .get<Record<HatShape, number>>("shapes")!; |
| 185 | const colorPenalties = vscode.workspace |
| 186 | .getConfiguration("cursorless.hatPenalties") |
| 187 | .get<Record<HatColor, number>>("colors")!; |
| 188 | |
| 189 | shapeEnablement.default = true; |
| 190 | colorEnablement.default = true; |
| 191 | shapePenalties.default = 0; |
| 192 | colorPenalties.default = 0; |
| 193 | |
| 194 | // So that unit tests don't fail locally if you have some colors disabled |
| 195 | const activeHatColors = isTesting() |
| 196 | ? HAT_COLORS.filter((color) => !color.startsWith("user")) |
| 197 | : HAT_COLORS.filter((color) => colorEnablement[color]); |
| 198 | const activeNonDefaultHatShapes = HAT_NON_DEFAULT_SHAPES.filter( |
| 199 | (shape) => shapeEnablement[shape] |
| 200 | ); |
| 201 | |
| 202 | this.hatStyleMap = { |
| 203 | ...Object.fromEntries( |
| 204 | activeHatColors.map((color) => [color, { color, shape: "default" }]) |
| 205 | ), |
| 206 | ...Object.fromEntries( |
| 207 | activeHatColors.flatMap((color) => |
| 208 | activeNonDefaultHatShapes.map((shape) => [ |
| 209 | `${color}-${shape}`, |
| 210 | { color, shape }, |
| 211 | ]) |
| 212 | ) |
| 213 | ), |
| 214 | } as Record<HatStyleName, HatStyle>; |
| 215 | |
| 216 | this.hatStyleNames = sortBy( |
| 217 | Object.entries(this.hatStyleMap), |
| 218 | ([_, hatStyle]) => |
| 219 | colorPenalties[hatStyle.color] + shapePenalties[hatStyle.shape] |
| 220 | ).map(([hatStyleName, _]) => hatStyleName as HatStyleName); |
| 221 | } |
| 222 | |
| 223 | private constructColoredSvgDataUri(originalSvg: string, color: string) { |
| 224 | if ( |
no test coverage detected