Icon theme with overrides from config#792
Merged
zwpaper merged 4 commits intolsd-rs:masterfrom Apr 22, 2023
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #792 +/- ##
==========================================
+ Coverage 86.57% 86.63% +0.05%
==========================================
Files 44 44
Lines 4507 4527 +20
==========================================
+ Hits 3902 3922 +20
Misses 605 605
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
meain
reviewed
Jan 22, 2023
| pub struct IconTheme { | ||
| pub name: HashMap<String, String>, | ||
| pub extension: HashMap<String, String>, | ||
| #[serde(deserialize_with = "deserialize_by_name")] |
Member
There was a problem hiding this comment.
If we are using a custom deserialize, I think we can avoid creating separate structs.
Contributor
Author
There was a problem hiding this comment.
I totally agree with you. I updated the PR. (5e81871)
34bc764 to
5e81871
Compare
5e81871 to
4461ffc
Compare
Member
|
thanks so much, @sudame, it works like a charm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR will close #780
Background
👀 A detailed discussion can be found here: #780
When a user chooses to use custom icons, lsd should apply the custom icons for the conditions specified by the user, and use the default icons for all other conditions.
However, currently lsd ignores the default icons when a user sets custom icons.
Cause
The struct
IconThemehas HashMap fields namednameandextension. The Serde (Rust's deserialization module) can merge default values for structs, but it cannot do so for HashMap. As a result, thenameandextensionfields will not be merged if a custom configuration exists.What I did
ByFilenamestruct which wraps a HashMap for thenameandextensionfields.ByFilenamehas the IntoIterator trait to minimize the impact on other parts of the code.ByFilename.Comments
The number of added and removed lines in this PR is significant because I had to move the default icon settings.
TODO
cargo fmtUpdate default config/theme in README (if applicable)Update man page at lsd/doc/lsd.md (if applicable)