Skip to content

Commit 4afe3b5

Browse files
Use iteration colors in scope visualizer in document page (#3028)
1 parent 60f85b7 commit 4afe3b5

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

packages/cursorless-org-docs/src/docs/components/ScopeVisualizer.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ function renderFacet(
207207
}}
208208
languageId={languageId ?? fixture.languageId}
209209
renderWhitespace={renderWhitespace}
210-
decorations={generateDecorations(fixture, rangeType)}
210+
decorations={generateDecorations(
211+
fixture,
212+
rangeType,
213+
facet.info.isIteration ?? false,
214+
)}
211215
>
212216
{fixture.code}
213217
</Code>

packages/cursorless-org-docs/src/docs/components/calculateHighlights.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ import type { Fixture, Highlight, RangeType, RangeTypeColors } from "./types";
1313
export function generateDecorations(
1414
fixture: Fixture,
1515
rangeType: RangeType,
16+
isIteration: boolean,
1617
): DecorationItem[] {
1718
const { domainRanges, targetRanges } = getRanges(fixture, rangeType);
1819

1920
const codeLineRanges = getCodeLineRanges(fixture.code);
20-
const colors = getColors(rangeType);
21+
const colors = getColors(rangeType, isIteration);
2122

2223
const domainDecorations = getDecorations(codeLineRanges, domainRanges);
2324
const targetRangeDecorations = getDecorations(codeLineRanges, targetRanges);
@@ -37,13 +38,19 @@ export function generateDecorations(
3738
return highlightsToDecorations(highlights);
3839
}
3940

40-
function getColors(rangeType: RangeType) {
41+
function getColors(rangeType: RangeType, isIteration: boolean) {
42+
const target = (() => {
43+
if (isIteration) {
44+
return highlightColors.iteration;
45+
}
46+
if (rangeType === "content") {
47+
return highlightColors.content;
48+
}
49+
return highlightColors.removal;
50+
})();
4151
return {
4252
domain: highlightColors.domain,
43-
target:
44-
rangeType === "content"
45-
? highlightColors.content
46-
: highlightColors.removal,
53+
target,
4754
};
4855
}
4956

0 commit comments

Comments
 (0)