Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add case_sensitive_ext option for mimetype, theme and icons #497

Merged
merged 4 commits into from
Mar 11, 2024

Conversation

Akmadan23
Copy link
Contributor

Currently any file with an uppercase or partially uppercase extension is not recognized by either mimetype.toml, theme.toml and icons.toml. With this addition, when the flag is set to false, any uppercase/lowercase variant of an extension will be correctly detected. I set it to false by default because it just makes sense to me, but we can set it to true if we want to keep the current behavior by default.

src/main.rs Outdated
@@ -68,6 +68,8 @@ lazy_static! {

config_dirs
};

static ref CONFIG_T: AppConfig = AppConfig::get_config();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having it as a static reference here seems to be the only solution... That's not a problem right?

Copy link
Owner

@kamiyaa kamiyaa Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of making the config static, I think the less intrusive approach is to just check the config to see if option is enabled and pass the already lowercase version into app_list_for_ext.

ie. inside open_file.rs, change _get_options to take &AppConfig as a parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that works but just for the mimetype part, for theme and icons there is something more to do, but I'll try

@Akmadan23
Copy link
Contributor Author

Here is the new implementation, which involves a lot of extra clones, not sure if that's better than having a static config.

Speaking of clones, I was wondering if it would be a good idea to do a major refactor using only one static config (like THEME_T, MIMETYPE_T, etc.) and keeping in the context just a minimal config to be used only for mutable values. It would drastically decrease clones and improve both memory and cpu performance. Let me know your thoughts on this...

@kamiyaa
Copy link
Owner

kamiyaa commented Mar 10, 2024

Here is the new implementation, which involves a lot of extra clones, not sure if that's better than having a static config.

Speaking of clones, I was wondering if it would be a good idea to do a major refactor using only one static config (like THEME_T, MIMETYPE_T, etc.) and keeping in the context just a minimal config to be used only for mutable values. It would drastically decrease clones and improve both memory and cpu performance. Let me know your thoughts on this...

Yeah, the issue is with static, its read-only I believe.
So we won't be able to modify the configs (ie. show_hidden).
I guess we can get around this with an Arc<> or something

@kamiyaa kamiyaa merged commit cd93314 into kamiyaa:main Mar 11, 2024
4 checks passed
@Akmadan23 Akmadan23 deleted the case_sensitive_ext branch March 11, 2024 15:32
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