@@ -15,62 +15,80 @@ export function generateDecorations(
1515 rangeType : RangeType ,
1616 isIteration : boolean ,
1717) : DecorationItem [ ] {
18- const { domainRanges, targetRanges } = getRanges ( fixture , rangeType ) ;
18+ const { domainRanges, removalRanges, contentRanges } = getRanges (
19+ fixture ,
20+ rangeType ,
21+ ) ;
1922
2023 const codeLineRanges = getCodeLineRanges ( fixture . code ) ;
21- const colors = getColors ( rangeType , isIteration ) ;
22-
23- const domainDecorations = getDecorations ( codeLineRanges , domainRanges ) ;
24- const targetRangeDecorations = getDecorations ( codeLineRanges , targetRanges ) ;
2524
26- const domainHighlights = domainDecorations . map ( ( d ) =>
27- getHighlights ( colors . domain , d . range , d . style ) ,
28- ) ;
29- const targetRangeHighlights = targetRangeDecorations . map ( ( d ) =>
30- getHighlights ( colors . target , d . range , d . style ) ,
25+ const highlights = getDecorations ( codeLineRanges , domainRanges ) . map ( ( d ) =>
26+ getHighlights ( highlightColors . domain , d . range , d . style ) ,
3127 ) ;
3228
33- const highlights = flattenHighlights ( [
34- ...domainHighlights ,
35- ...targetRangeHighlights ,
36- ] ) ;
29+ if ( rangeType === "blend" && ! isIteration ) {
30+ const removalHighlights = getDecorations ( codeLineRanges , removalRanges ) . map (
31+ ( d ) => getHighlights ( highlightColors . removal , d . range , d . style ) ,
32+ ) ;
33+ const contentHighlights = getDecorations ( codeLineRanges , contentRanges ) . map (
34+ ( d ) => getHighlights ( highlightColors . content , d . range , d . style ) ,
35+ ) ;
36+
37+ highlights . push ( ...removalHighlights , ...contentHighlights ) ;
38+ } else {
39+ const colors = getColors ( rangeType , isIteration ) ;
40+ const targetRangeHighlights = getDecorations (
41+ codeLineRanges ,
42+ rangeType === "removal" ? removalRanges : contentRanges ,
43+ ) . map ( ( d ) => getHighlights ( colors , d . range , d . style ) ) ;
3744
38- return highlightsToDecorations ( highlights ) ;
45+ highlights . push ( ...targetRangeHighlights ) ;
46+ }
47+
48+ const flattenedHighlights = flattenHighlights ( highlights ) ;
49+
50+ return highlightsToDecorations ( flattenedHighlights ) ;
3951}
4052
4153function 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- } ) ( ) ;
51- return {
52- domain : highlightColors . domain ,
53- target,
54- } ;
54+ if ( isIteration ) {
55+ return highlightColors . iteration ;
56+ }
57+ if ( rangeType === "content" ) {
58+ return highlightColors . content ;
59+ }
60+ return highlightColors . removal ;
5561}
5662
5763function getRanges ( fixture : Fixture , rangeType : RangeType ) {
58- const domainRanges : Range [ ] = [ ] ;
59- const targetRanges : Range [ ] = [ ] ;
64+ const domainRanges : string [ ] = [ ] ;
65+ const removalRanges : string [ ] = [ ] ;
66+ const contentRanges : string [ ] = [ ] ;
6067
6168 for ( const { domain, targets } of fixture . scopes ) {
6269 if ( domain != null ) {
63- domainRanges . push ( Range . fromConcise ( domain ) ) ;
70+ domainRanges . push ( domain ) ;
6471 }
6572
6673 for ( const t of targets ) {
67- const range =
68- rangeType === "content" ? t . content : ( t . removal ?? t . content ) ;
69- targetRanges . push ( Range . fromConcise ( range ) ) ;
74+ if ( rangeType === "blend" ) {
75+ if ( t . removal != null ) {
76+ removalRanges . push ( t . removal ) ;
77+ }
78+ contentRanges . push ( t . content ) ;
79+ } else if ( rangeType === "removal" ) {
80+ removalRanges . push ( t . removal ?? t . content ) ;
81+ } else {
82+ contentRanges . push ( t . content ) ;
83+ }
7084 }
7185 }
7286
73- return { domainRanges, targetRanges } ;
87+ return {
88+ domainRanges : domainRanges . map ( Range . fromConcise ) ,
89+ removalRanges : removalRanges . map ( Range . fromConcise ) ,
90+ contentRanges : contentRanges . map ( Range . fromConcise ) ,
91+ } ;
7492}
7593
7694function getHighlights (
0 commit comments