Skip to content

feat: show error when image preview fails#2706

Merged
sxyazi merged 1 commit intomainfrom
pr-f35b1bb9
May 1, 2025
Merged

feat: show error when image preview fails#2706
sxyazi merged 1 commit intomainfrom
pr-f35b1bb9

Conversation

@sxyazi
Copy link
Owner

@sxyazi sxyazi commented May 1, 2025

Before this change, when ya.image_info() and ya.image_show() failed, there was no way to determine the reason for the failure.

With this PR, a new second return value has been added to them, in the event of a failure, it will carry an Error userdata that provides the caller with the error message.

All built-in image previewers in Yazi have been updated to support this, that is, when an image preview fails, the error will be displayed in the preview pane so that the user knows what went wrong.

Deprecated API

ya.preview_widgets() has been deprecated and replaced by the new ya.preview_widget():

- ya.preview_widgets(job, { ui.Text("..."):area(job.area) })
+ ya.preview_widget(job, { ui.Text("..."):area(job.area) })

In addition to supporting the table parameter as the original ya.preview_widgets() did, the new ya.preview_widget() can also accept a single renderable element directly without the need to wrap it in a table:

- ya.preview_widgets(job, { ui.Text("..."):area(job.area) })
+ ya.preview_widget(job, ui.Text("..."):area(job.area))

Considering that ya.preview_widgets() has been widely used in previewers, it will continue to be available for a long time. Deprecation warnings will be added later, and it will eventually be removed.

@sxyazi sxyazi merged commit d6a01a6 into main May 1, 2025
6 checks passed
@sxyazi sxyazi deleted the pr-f35b1bb9 branch May 1, 2025 14:58
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant