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

Path name is truncated (and inconsistently) #11

Closed
lazywei opened this issue Jan 23, 2023 · 4 comments
Closed

Path name is truncated (and inconsistently) #11

lazywei opened this issue Jan 23, 2023 · 4 comments

Comments

@lazywei
Copy link

lazywei commented Jan 23, 2023

It seems sometimes the filepath is truncated, for example, I have a file in tools/foobar_query_benchmark/main.go
And when I type in bench/main I can find the file but the path was truncated. At the same time, other file with longer path doesn't get truncated.
image

I wonder if there is a way to configure so that either:

  1. Everything is truncated based on an consistent length limit, or
  2. Allow the user to disable the truncation

Again, thanks for the plugin I'm already enjoying the quickness when working on a large codebase.

@danielfalk
Copy link
Owner

I think this is consistent in the sense that it's truncating directory names longer than 16 chars. Yeah...it's an odd default that's not called out anywhere, It's using the shorten = 16 option from telescope.nvim.

This is definitely a weakness we have when using terminal-based applications, since we can't use a variable width typeface that would allow us to use so much less space for these.

Ideally there wouldn't need to be any options here because we'd just be able to do the most reasonable thing always. If anybody has any thoughts or examples of some project doing this well, I'd love to know about it.

I don't care for the way telescope shortens directories. I'd much prefer if it only shortens as much as it would need to make the directory fit, but for that, the path_display transformation functions would have to accept an "available length" parameter. At the very least though, I think we can expose an option that allows us to fall back to configuring the display of paths using telescope's options.

danielfalk pushed a commit that referenced this issue Feb 28, 2023
* Use a different highlighting group instead of parentheses for
  differentiating the directory vs. the filename
* Use the width of the results window to decide how aggressively
  to shorten path names
* Create tests for formatting functions

Fixes #11
@danielfalk
Copy link
Owner

This change is available on the 0.2.x branch, which is in a sort of pre-release state right now, so if you want to try it out and provide feedback, that would be great. I ended up creating a custom path formatter because I couldn't find anything existing that tried to give as much path information as possible given a space constraint. Also, I switched to using a highlighting class of Directory to give the directory a different color. I like the looks of this, so hopefully it's the correct way to use the highlighting class?

If there's anyone who can provide feedback on this, it would be a big help.

@lazywei
Copy link
Author

lazywei commented Feb 28, 2023

It looks great! I just tried it and I think it works for whatever I have right now. Not sure if there is any edge case but at least it's working for me.
One thing not sure if related to the custom formatter: it seems the results are blinking/refreshing quite a bit whenever I'm typing. Maybe it's due to the refreshing period too short? It's not a big deal just some nitpick.

Thanks for working on this! It's a daily plugin for me :)

@danielfalk
Copy link
Owner

Implemented on 0.2.x branch.

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

No branches or pull requests

2 participants