@@ -23,6 +23,10 @@ import { Disposable } from 'vscode-languageserver'
2323
2424import { DOMFunctions } from '@sourcegraph/codeintellify'
2525import * as H from 'history'
26+ import {
27+ decorationAttachmentStyleForTheme ,
28+ decorationStyleForTheme ,
29+ } from 'sourcegraph/module/client/providers/decoration'
2630import { isErrorLike } from '../../shared/backend/errors'
2731import { createExtensionsContextController , createMessageTransports } from '../../shared/backend/extensions'
2832import { GlobalDebug } from '../../shared/components/GlobalDebug'
@@ -141,6 +145,8 @@ const mergeDisposables = (...disposables: Disposable[]): Disposable => ({
141145 } ,
142146} )
143147
148+ const IS_LIGHT_THEME = true // assume all code hosts have a light theme (correct for now)
149+
144150/**
145151 * Applies a decoration to a code view. This doesn't work with diff views yet.
146152 */
@@ -162,8 +168,9 @@ export const applyDecoration = (
162168 throw new Error ( `Unable to find code element for line ${ lineNumber } ` )
163169 }
164170
165- if ( decoration . backgroundColor ) {
166- codeElement . style . backgroundColor = decoration . backgroundColor
171+ const style = decorationStyleForTheme ( decoration , IS_LIGHT_THEME )
172+ if ( style . backgroundColor ) {
173+ codeElement . style . backgroundColor = style . backgroundColor
167174 disposables . push ( {
168175 dispose : ( ) => {
169176 codeElement . style . backgroundColor = null
@@ -172,6 +179,8 @@ export const applyDecoration = (
172179 }
173180
174181 if ( decoration . after ) {
182+ const style = decorationAttachmentStyleForTheme ( decoration . after , IS_LIGHT_THEME )
183+
175184 const linkTo = ( url : string ) => ( e : HTMLElement ) : HTMLElement => {
176185 const link = document . createElement ( 'a' )
177186 link . className = 'sourcegraph-extension-element'
@@ -184,14 +193,14 @@ export const applyDecoration = (
184193 // Avoid leaking referrer URLs (which contain repository and path names, etc.) to external sites.
185194 link . setAttribute ( 'rel' , 'noreferrer noopener' )
186195
187- link . style . color = decoration . after ! . color || null
196+ link . style . color = style . color || null
188197 link . appendChild ( e )
189198 return link
190199 }
191200
192201 const after = document . createElement ( 'span' )
193202 after . className = 'sourcegraph-extension-element'
194- after . style . backgroundColor = decoration . after . backgroundColor || null
203+ after . style . backgroundColor = style . backgroundColor || null
195204 after . textContent = decoration . after . contentText || null
196205 after . title = decoration . after . hoverMessage || ''
197206
0 commit comments