This commit is contained in:
Kovid Goyal
2025-07-20 19:30:26 +05:30
parent bd0f55531f
commit 92988c19c0

View File

@@ -184,11 +184,12 @@ type TextFilePreview struct {
plain_text, highlighted_text string plain_text, highlighted_text string
highlighted_chan chan highlighed_data highlighted_chan chan highlighed_data
light bool light bool
path string
} }
func (p TextFilePreview) IsValidForColorScheme(light bool) bool { return p.light == light } func (p TextFilePreview) IsValidForColorScheme(light bool) bool { return p.light == light }
func (p TextFilePreview) Render(h *Handler, x, y, width, height int) { func (p *TextFilePreview) Render(h *Handler, x, y, width, height int) {
if p.highlighted_chan != nil { if p.highlighted_chan != nil {
select { select {
case hd := <-p.highlighted_chan: case hd := <-p.highlighted_chan:
@@ -228,7 +229,7 @@ func NewTextFilePreview(abspath string, metadata fs.FileInfo, highlighted_chan c
if !utf8.ValidString(text) { if !utf8.ValidString(text) {
text = "Error: not valid utf-8 text" text = "Error: not valid utf-8 text"
} }
return &TextFilePreview{plain_text: sanitize(text), highlighted_chan: highlighted_chan, light: use_light_colors} return &TextFilePreview{path: abspath, plain_text: sanitize(text), highlighted_chan: highlighted_chan, light: use_light_colors}
} }
type style_resolver struct { type style_resolver struct {