Skip to content

fix(schemas/theme.json): use anyOf in determining mime or url#59

Merged
uncenter merged 1 commit intoyazi-rs:mainfrom
soraxas:fix-theme
Jan 14, 2026
Merged

fix(schemas/theme.json): use anyOf in determining mime or url#59
uncenter merged 1 commit intoyazi-rs:mainfrom
soraxas:fix-theme

Conversation

@soraxas
Copy link
Copy Markdown
Contributor

@soraxas soraxas commented Jan 14, 2026

The language stated in https://yazi-rs.github.io/docs/configuration/theme is unclear

noting that it must be used with either url or mime. It accepts the following values:

But in code, https://github.com/sxyazi/yazi/blob/0c8c973e6c766ff026665e487a33ad82f0c7e4f8/yazi-config/src/theme/filetype.rs#L37-L40

impl FiletypeRule {
	pub fn matches(&self, file: &File, mime: &str) -> bool {
		if !self.is.check(&file.cha) {
			return false;
		}

		self.mime.as_ref().is_some_and(|p| p.match_mime(mime))
			|| self.url.as_ref().is_some_and(|n| n.match_url(&file.url, file.is_dir()))
	}
}

you can see that the filter supports either OR; not XOR.

Using anyOf fixes the lint error like:

{"mime":"message/rfc822","url":"*.eml","bold":true,"fg":"#870087"} is 
valid under more than one of the schemas listed in the 'oneOf' keywordEven Better TOML

when both mime and url are used.

Signed-off-by: Tin Lai <tin@tinyiu.com>
@uncenter uncenter changed the title use anyOf in determining mime or url in theme.toml fix(schemas/theme.json): use anyOf in determining mime or url Jan 14, 2026
@uncenter uncenter merged commit 681f312 into yazi-rs:main Jan 14, 2026
1 check passed
@soraxas soraxas deleted the fix-theme branch January 15, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants