mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
move json fallback to inside Provider::json function
This commit is contained in:
parent
5f192d2f5d
commit
9c5e8730be
1 changed files with 4 additions and 5 deletions
|
|
@ -30,10 +30,7 @@ impl Provider {
|
||||||
MimeKind::Archive => Provider::archive(path, skip).await.map(PreviewData::Text),
|
MimeKind::Archive => Provider::archive(path, skip).await.map(PreviewData::Text),
|
||||||
MimeKind::Image => Provider::image(path).await,
|
MimeKind::Image => Provider::image(path).await,
|
||||||
MimeKind::Video => Provider::video(path, skip).await,
|
MimeKind::Video => Provider::video(path, skip).await,
|
||||||
MimeKind::JSON => Provider::json(path, skip)
|
MimeKind::JSON => Provider::json(path, skip).await.map(PreviewData::Text),
|
||||||
.or_else(|_| Provider::highlight(path, skip))
|
|
||||||
.await
|
|
||||||
.map(PreviewData::Text),
|
|
||||||
MimeKind::PDF => Provider::pdf(path, skip).await,
|
MimeKind::PDF => Provider::pdf(path, skip).await,
|
||||||
MimeKind::Text => Provider::highlight(path, skip).await.map(PreviewData::Text),
|
MimeKind::Text => Provider::highlight(path, skip).await.map(PreviewData::Text),
|
||||||
MimeKind::Others => Err("Unsupported mimetype".into()),
|
MimeKind::Others => Err("Unsupported mimetype".into()),
|
||||||
|
|
@ -77,7 +74,9 @@ impl Provider {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn json(path: &Path, skip: usize) -> Result<String, PeekError> {
|
pub(super) async fn json(path: &Path, skip: usize) -> Result<String, PeekError> {
|
||||||
external::jq(path, skip, MANAGER.layout.preview_height()).await
|
external::jq(path, skip, MANAGER.layout.preview_height())
|
||||||
|
.or_else(|_| Provider::highlight(path, skip))
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn archive(path: &Path, skip: usize) -> Result<String, PeekError> {
|
pub(super) async fn archive(path: &Path, skip: usize) -> Result<String, PeekError> {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue