Why is the value and ouptut on clicking the same ?
Problem Statement
Supose you are using a Suggestion struct like this:
Some(Suggestion {
description: file_path,
value: file_name,
style: None,
extra: None,
span: query.span,
append_whitespace: true,
})
Goal
You want the suggestion to display in the following format:
[file_name] [dir/dir/file_name]
However, when the suggestion is selected, you want the file path (dir/dir/file_name) to be the inserted text — not just the file name.
Why Not Just Swap description and value?
If you swap them like this:
description: file_name,
value: file_path,
It will correctly insert the full path when selected, but there's a catch.
The Highlighting Problem
The highlighter operates on the value field. So when the value is file_path, the highlighter may incorrectly underline matches in the path (like directory names) rather than in the file name. For example:
- If both
file_dirandfile_namecontain similar substrings, the highlighter might highlight the directory part (file_dir) instead of the actual file name — which is not desirable. - What you want is the file name portion to be emphasized in the display, not other parts of the path.
Summary
You want:
-
Display:
file_name(on the left),file_path(on the right). -
Insertion:
file_path. -
Highlighting: should match the
file_name, not parts of thefile_path.
But due to the current structure where:
-
valuecontrols both insertion and highlighting, - and
descriptionis only visual and non-selectable,
you're unable to meet all three goals simultaneously.
I want help in this.
Unfortunately, I don't think there's currently a way to do what you want. This is something we want to improve. We haven't come to a decision on how exactly to implement it, but one suggestion that was put forth was having a separate display_text: String field inside Suggestion, and I'm assuming that's the path we'll take. The user would be shown display_text (the shortened file name), but when completing, value (the full file path) would be used.
ya,first I thought why not should I simply just display it my self, but the issues comes as in the Case 2: the matcher and the highlighter problem also , which confuses everyhitng .
I am currently implementing it in a project.
Hi is there any way in which if I match something then highlight only the last match of it
say I have [crates/project_aps/shapshot.rs] and ifI search aps then the first aps in the dir_name project_aps get underlined but I want that shapshot.rs get underlines ?
Not with our current menus, I'm afraid. This is being worked on, though.