eza
eza copied to clipboard
fix(theme): support multi-codepoint emojis in theme.yml glyph field
Summary
Fixes #1654 - Adds support for multi-codepoint emojis in theme.yml glyph fields.
Problem
Emojis with Unicode variation selectors (πΌοΈ, π₯οΈ) and other multi-codepoint sequences caused the entire theme.yml file to be silently ignored. The glyph field was typed as Option<char>, which can only hold single Unicode scalar values.
Solution
Changed the glyph field from Option<char> to Option<String> to support:
- β Emojis with variation selectors (U+FE0F): πΌοΈ π₯οΈ βοΈ βοΈ
- β ZWJ (Zero Width Joiner) sequences: π¨βπ» π©βπ¨ π¨βπ©βπ§βπ¦
- β Flag emojis (regional indicators): πΊπΈ π¬π§ π―π΅
- β Skin tone modifiers: ππ» ππΏ
Also improved error handling to report theme parsing failures instead of silently failing.
Changes
Type Changes
src/theme/ui_styles.rs: ChangedIconStyle::glyphfromOption<char>toOption<String>src/options/config.rs: ChangedIconStyleOverride::glyphfromOption<char>toOption<String>- Removed
Copytrait from structs containingStringfields (IconStyle,FileNameStyle,IconStyleOverride,FileNameStyleOverride)
Function Updates
src/output/icons.rs: Changedicon_for_file()return type fromchartoStringsrc/output/file_name.rs: Updated icon usage to work withStringtypesrc/theme/mod.rs: Changed from dereferencing to cloning for non-Copy types
Error Handling
src/options/config.rs: Replaced silent.ok()with explicit error messages when theme parsing fails
Testing
Added 7 comprehensive unit tests covering:
- Single-codepoint emojis (πΎ)
- Emojis with variation selectors (πΌοΈ, π₯οΈ)
- ZWJ sequences (π¨βπ»)
- Regional indicator sequences (πΊπΈ)
- Mixed emoji themes
- Empty glyph strings
- Invalid YAML error handling
Test Results:
- All 462 tests pass β
- No clippy warnings β
- Code formatted with
cargo fmtβ
Backward Compatibility
Fully backward compatible - existing single-character icons continue to work without changes.
Example Usage
# ~/.config/eza/theme.yml
filenames:
data: {icon: {glyph: πΎ}} # Single codepoint - works
Pictures: {icon: {glyph: πΌοΈ}} # Variation selector - now works!
Desktop: {icon: {glyph: π₯οΈ}} # Variation selector - now works!
developer: {icon: {glyph: π¨βπ»}} # ZWJ sequence - now works!
extensions:
rs: {icon: {glyph: π¦}}
py: {icon: {glyph: π}}
Checklist
- [x] Tests pass (
cargo test) - [x] No clippy warnings (
cargo clippy) - [x] Code formatted (
cargo fmt) - [x] Follows conventional commits
- [x] References issue (#1654)
- [x] Backward compatible