mirror of
https://github.com/alecthomas/chroma.git
synced 2025-03-19 21:10:15 +02:00
fix: synthesisable entries are ignored when cloned (#465)
This commit is contained in:
parent
41b886a7fd
commit
d67a2bfdc2
6
style.go
6
style.go
@ -265,12 +265,12 @@ func (s *Style) Get(ttype TokenType) StyleEntry {
|
||||
|
||||
func (s *Style) get(ttype TokenType) StyleEntry {
|
||||
out := s.entries[ttype]
|
||||
if out.IsZero() && s.synthesisable(ttype) {
|
||||
out = s.synthesise(ttype)
|
||||
}
|
||||
if out.IsZero() && s.parent != nil {
|
||||
return s.parent.get(ttype)
|
||||
}
|
||||
if out.IsZero() && s.synthesisable(ttype) {
|
||||
out = s.synthesise(ttype)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
|
@ -48,3 +48,18 @@ func TestSynthesisedStyleEntries(t *testing.T) {
|
||||
assert.Equal(t, "#7f7f7f bg:#ffffff", style.Get(LineNumbers).String())
|
||||
assert.Equal(t, "#7f7f7f bg:#ffffff", style.Get(LineNumbersTable).String())
|
||||
}
|
||||
|
||||
func TestSynthesisedStyleClone(t *testing.T) {
|
||||
style, err := NewStyle("test", StyleEntries{
|
||||
Background: "bg:#ffffff",
|
||||
LineHighlight: "bg:#ffffff",
|
||||
LineNumbers: "bg:#fffff1",
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
style, err = style.Builder().Build()
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, style.Has(LineHighlight))
|
||||
assert.True(t, style.Has(LineNumbers))
|
||||
assert.Equal(t, "bg:#ffffff", style.Get(LineHighlight).String())
|
||||
assert.Equal(t, "bg:#fffff1", style.Get(LineNumbers).String())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user