MCPcopy Create free account
hub / github.com/cursorless-dev/cursorless / constructDecorations

Method constructDecorations

src/core/Decorations.ts:93–173  ·  view source on GitHub ↗
(fontMeasurements: FontMeasurements)

Source from the content-addressed store, hash-verified

91 }
92
93 private constructDecorations(fontMeasurements: FontMeasurements) {
94 this.constructHatStyleMap();
95
96 const userSizeAdjustment = vscode.workspace
97 .getConfiguration("cursorless")
98 .get<number>(`hatSizeAdjustment`)!;
99
100 const userVerticalOffset = vscode.workspace
101 .getConfiguration("cursorless")
102 .get<number>(`hatVerticalOffset`)!;
103
104 const userIndividualAdjustments = vscode.workspace
105 .getConfiguration("cursorless")
106 .get<IndividualHatAdjustmentMap>("individualHatAdjustments")!;
107
108 const hatSvgMap = Object.fromEntries(
109 HAT_SHAPES.map((shape) => {
110 const { sizeAdjustment = 0, verticalOffset = 0 } =
111 defaultShapeAdjustments[shape];
112
113 const {
114 sizeAdjustment: userIndividualSizeAdjustment = 0,
115 verticalOffset: userIndividualVerticalOffset = 0,
116 } = userIndividualAdjustments[shape] ?? {};
117
118 const scaleFactor =
119 1 +
120 (sizeAdjustment + userSizeAdjustment + userIndividualSizeAdjustment) /
121 100;
122
123 const finalVerticalOffsetEm =
124 (verticalOffset + userVerticalOffset + userIndividualVerticalOffset) /
125 100;
126
127 return [
128 shape,
129 this.processSvg(
130 fontMeasurements,
131 shape,
132 scaleFactor,
133 finalVerticalOffsetEm
134 ),
135 ];
136 })
137 );
138
139 this.decorations = this.hatStyleNames.map((styleName) => {
140 const { color, shape } = this.hatStyleMap[styleName];
141 const { svg, svgWidthPx, svgHeightPx } = hatSvgMap[shape];
142
143 const { light, dark } = getHatThemeColors(color);
144
145 return {
146 name: styleName,
147 decoration: vscode.window.createTextEditorDecorationType({
148 rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed,
149 light: {
150 before: {

Callers 2

initMethod · 0.95

Calls 5

constructHatStyleMapMethod · 0.95
processSvgMethod · 0.95
getHatThemeColorsFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected