mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 10:41:58 +02:00
Show file metadata based preview with an error message when preview fails to render
This commit is contained in:
@@ -157,7 +157,7 @@ func (p *ImagePreview) Render(h *Handler, x, y, width, height int) {
|
|||||||
p.source_img = hd.img
|
p.source_img = hd.img
|
||||||
p.custom_metadata = hd.metadata
|
p.custom_metadata = hd.metadata
|
||||||
if hd.err != nil {
|
if hd.err != nil {
|
||||||
p.render_err = NewErrorPreview(fmt.Errorf("Failed to render the preview with error: %w", hd.err))
|
p.render_err = NewFileMetadataPreviewWithError(p.abspath, p.metadata, fmt.Errorf("Failed to render the preview with error: %w", hd.err))
|
||||||
}
|
}
|
||||||
p.Render(h, x, y, width, height)
|
p.Render(h, x, y, width, height)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ func NewFileMetadataPreviewWithError(abspath string, metadata fs.FileInfo, err e
|
|||||||
h, t := write_file_metadata(abspath, metadata, nil)
|
h, t := write_file_metadata(abspath, metadata, nil)
|
||||||
ans := &MessagePreview{title: title, msg: h, trailers: t}
|
ans := &MessagePreview{title: title, msg: h, trailers: t}
|
||||||
lines := style.WrapTextAsLines(err.Error(), 30, style.WrapOptions{})
|
lines := style.WrapTextAsLines(err.Error(), 30, style.WrapOptions{})
|
||||||
|
ans.trailers = append(ans.trailers, "")
|
||||||
ans.trailers = append(ans.trailers, lines...)
|
ans.trailers = append(ans.trailers, lines...)
|
||||||
return ans
|
return ans
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user