Repository navigation
Remove folder name prefix in autocompletion suggestions - #11250
TheRealFalcon wants to merge 3 commits into
Conversation
| prefix.push_utfstr(&full[full.len() - PREFIX_MAX_LEN..]); | ||
| let truncated = &full[full.len() - PREFIX_MAX_LEN..]; | ||
| let parts: Vec<&wstr> = truncated.split('/').collect(); | ||
| if parts.len() < 2 { |
There was a problem hiding this comment.
Seems like a good change. I'll try it for a while.
I haven't re-read the issue yet - maybe we can briefly summarize the reason for this change.
I gues zsh will only show the basename even if there is no truncation going on,
but we don't need to go there - your approach is safer.
There was a problem hiding this comment.
after re-reading the issue, I think we should eventually have a generic way
of making sure that the common prefix is not way larger than any of the suffixes.
But that can definitely be done later, and I expect that we'll still want to keep the special handling of "/".
| // any further | ||
| prefix.push_utfstr(&truncated); | ||
| } else { | ||
| // Discard any parent directories and include whats left |
There was a problem hiding this comment.
this works for absolute paths but it doesn't seem to work for ~/some/path, can we fix that?
| prefix.push_utfstr(&full[full.len() - PREFIX_MAX_LEN..]); | ||
| let truncated = &full[full.len() - PREFIX_MAX_LEN..]; | ||
| let parts: Vec<&wstr> = truncated.split('/').collect(); | ||
| if parts.len() < 2 { |
There was a problem hiding this comment.
parts.len() < 2 is a bit confusing because there's always at least one part.
Better make that obvious by checking parts.len() == 1.
Actually we should also get rid of the gratuitous vector, how about
let (i, last_component) = truncated.split('/').enumerate().last().unwrap();
if i == 0 {
// No path separators were found in the common prefix, so we can't collapse
// any further
prefix.push_utfstr(&truncated);
} else {
// Discard any parent directories and include whats left
prefix.push('/');
prefix.push_utfstr(last_component);
};| prefix.push_utfstr(&full[full.len() - PREFIX_MAX_LEN..]); | ||
| let truncated = &full[full.len() - PREFIX_MAX_LEN..]; | ||
| let parts: Vec<&wstr> = truncated.split('/').collect(); | ||
| if parts.len() < 2 { |
There was a problem hiding this comment.
I'm wondering if we should also allow = and : as separators, since we sort of do that when computing completions.
I guess let's wait until we find a use case; the LHS is not usually very large.
| prefix.push_utfstr(&common_prefix); | ||
| } else { | ||
| // Append just the end of the string. | ||
| // Collapse parent directories and append end of string |
There was a problem hiding this comment.
should probably add to the changelog, maybe something like
- When tab completion results are truncated, the common directory name is omitted.
| prefix.push_utfstr(&common_prefix); | ||
| } else { | ||
| // Append just the end of the string. | ||
| // Collapse parent directories and append end of string |
There was a problem hiding this comment.
This didn't break any tests locally for me. I'm willing to add new tests for this behavior, but I could use some direction as to where they would need to go and what sort of setup and/or mocking would be required.
We don't have mocking for src/reader.rs yet, so either add that or write
a system test, maybe in tmux-pager.fish. To run, use
cargo b && tests/test_driver.py target/debug tests/checks/tmux-pager.fish
|
I believe I have addressed all of the comments and added a new check file with some basic tests for this behavior. |
|
Thanks! :-) |


Description
Remove folder name prefix in autocompletion suggestions
Fixes issue #8618
Additional info
Example behavior:

This didn't break any tests locally for me. I'm willing to add new tests for this behavior, but I could use some direction as to where they would need to go and what sort of setup and/or mocking would be required.
TODOs: