Skip to content

Commit 15997eb

Browse files
alecthomasclaude
andcommitted
fix: forward SetTracing through Coalesce and RemappingLexer
Both wrappers hid the wrapped lexer's TracingLexer implementation, so tracing could not be enabled through them; delegatingLexer already forwards it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent a69d1c0 commit 15997eb

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

coalesce.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ func Coalesce(lexer Lexer) Lexer { return &coalescer{lexer} }
77

88
type coalescer struct{ Lexer }
99

10+
func (d *coalescer) SetTracing(enable bool) {
11+
if l, ok := d.Lexer.(TracingLexer); ok {
12+
l.SetTracing(enable)
13+
}
14+
}
15+
1016
func (d *coalescer) Tokenise(options *TokeniseOptions, text string) (iter.Seq[Token], error) {
1117
it, err := d.Lexer.Tokenise(options, text)
1218
if err != nil {

remap.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ func (r *remappingLexer) AnalyseText(text string) float32 {
1616
return r.lexer.AnalyseText(text)
1717
}
1818

19+
func (r *remappingLexer) SetTracing(enable bool) {
20+
if l, ok := r.lexer.(TracingLexer); ok {
21+
l.SetTracing(enable)
22+
}
23+
}
24+
1925
func (r *remappingLexer) SetAnalyser(analyser func(text string) float32) Lexer {
2026
r.lexer.SetAnalyser(analyser)
2127
return r

0 commit comments

Comments
 (0)