sayanarijit / xplr

A hackable, minimal, fast TUI file explorer
https://xplr.dev
MIT License
4.06k stars 75 forks source link

Incorrect style and meta for directory with extension in name #713

Closed abhinavnatarajan closed 2 months ago

abhinavnatarajan commented 2 months ago

For a directory with an extension in the directory name, e.g. "myDir.ext", the meta and style fields in the node_type are set incorrectly if config options are present for that extension. Minimum example: create a directory called myDir.ext and use the following config:

version = '0.21.8'
xplr.config.node_types.directory.meta.icon = "D"
xplr.config.node_types.extension.ext = { meta = { icon = "F"}}
xplr.config.node_types.file.meta.icon = "F"

Current output:

xplr_current

I think the current behaviour is not intuitive, since I would assume that the extension node type is meant to apply to regular files rather than directories. I would expect the output to be:

xplr_expected

The fix would be to check for a directory when extending the node meta and style fields with the config options that are set for extensions. The change would be in the following line: https://github.com/sayanarijit/xplr/blob/ad8afa9d38bef21ba72abcee03759db2725cc932/src/config.rs#L107

which would be changed to:

if let (Some(conf), false) = (self.extension.get(&node.extension), node.is_dir) {