@@ -31,7 +31,9 @@ export function SourceContents(
3131
3232 const simpleDecorations = Program . Context . isCode ( context )
3333 ? decorateCodeContext ( context , source )
34- : [ ] ;
34+ : Program . Context . isPick ( context )
35+ ? decoratePickContext ( context , source )
36+ : [ ] ;
3537
3638 const detailedDecorations = [
3739 ...simpleDecorations ,
@@ -56,7 +58,8 @@ export function SourceContents(
5658
5759function decorateCodeContext (
5860 { code } : Program . Context . Code ,
59- source : Materials . Source
61+ source : Materials . Source ,
62+ className : string = "highlighted-code"
6063) : Shiki . DecorationItem [ ] {
6164 const { offset, length } = normalizeRange ( code . range , source ) ;
6265
@@ -65,12 +68,29 @@ function decorateCodeContext(
6568 start : offset ,
6669 end : offset + length ,
6770 properties : {
68- class : "highlighted-code"
71+ class : className
6972 }
7073 }
7174 ] ;
7275}
7376
77+ function decoratePickContext (
78+ { pick } : Program . Context . Pick ,
79+ source : Materials . Source
80+ ) : Shiki . DecorationItem [ ] {
81+ // HACK this only supports picking from a choice of several different code
82+ // contexts
83+ if ( ! pick . every ( Program . Context . isCode ) ) {
84+ console . warn ( "decoratePickContext encountered non-code contexts in pick array. These will be ignored." ) ;
85+ return [ ] ;
86+ }
87+
88+ return pick . flatMap (
89+ ( choice ) => decorateCodeContext ( choice , source , "highlighted-ambiguous-code" )
90+ ) ;
91+ }
92+
93+
7494function decorateVariablesContext (
7595 { variables } : Program . Context . Variables ,
7696 source : Materials . Source
0 commit comments