fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

Don't truncate file before detecting language (#740)

Currently, we truncate a file's contents to 2048 bytes before passing it to
`go-enry`. I ran into a few cases where this is causing us to misclassify
files.

This PR removes the truncation. It should still be fine in terms of
performance, since `go-enry` is quite fast in general: ~1ms in my local
testing, even for large files. And we only run language detection if we plan to
index the file, which means we skip binary files and large files.

+1 -6
+1 -6
indexbuilder.go
··· 397 397 398 398 func DetermineLanguageIfUnknown(doc *Document) { 399 399 if doc.Language == "" { 400 - c := doc.Content 401 - // classifier is faster on small files without losing much accuracy 402 - if len(c) > 2048 { 403 - c = c[:2048] 404 - } 405 - doc.Language = enry.GetLanguage(doc.Name, c) 400 + doc.Language = enry.GetLanguage(doc.Name, doc.Content) 406 401 } 407 402 } 408 403