1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-17 20:58:08 +02:00

feat: ensure the analyse score is up to 1.0 (#832)

This commit is contained in:
Carlos Henrique Guardão Gandarez 2023-08-23 17:31:46 -03:00 committed by GitHub
parent 708662a581
commit 954c5ae915
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ import (
"fmt"
"io"
"io/fs"
"math"
"path/filepath"
"reflect"
"regexp"
@ -168,7 +169,7 @@ func NewXMLLexer(from fs.FS, path string) (*RegexLexer, error) {
}
if ok && config.Analyse.Single {
return ra.score
return float32(math.Min(float64(ra.score), 1.0))
}
if ok {
@ -176,7 +177,7 @@ func NewXMLLexer(from fs.FS, path string) (*RegexLexer, error) {
}
}
return score
return float32(math.Min(float64(score), 1.0))
}
}