mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 16:37:27 +00:00
Show file metadata based preview with an error message when preview fails to render
This commit is contained in:
parent
0c4cefd720
commit
7c52f727dc
2 changed files with 2 additions and 1 deletions
|
|
@ -157,7 +157,7 @@ func (p *ImagePreview) Render(h *Handler, x, y, width, height int) {
|
|||
p.source_img = hd.img
|
||||
p.custom_metadata = hd.metadata
|
||||
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)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -196,6 +196,7 @@ func NewFileMetadataPreviewWithError(abspath string, metadata fs.FileInfo, err e
|
|||
h, t := write_file_metadata(abspath, metadata, nil)
|
||||
ans := &MessagePreview{title: title, msg: h, trailers: t}
|
||||
lines := style.WrapTextAsLines(err.Error(), 30, style.WrapOptions{})
|
||||
ans.trailers = append(ans.trailers, "")
|
||||
ans.trailers = append(ans.trailers, lines...)
|
||||
return ans
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue