reedline icon indicating copy to clipboard operation
reedline copied to clipboard

Why is the value and ouptut on clicking the same ?

Open SumitKumar-17 opened this issue 9 months ago • 4 comments

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_dir and file_name contain 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:

  1. Display: file_name (on the left), file_path (on the right).
  2. Insertion: file_path.
  3. Highlighting: should match the file_name, not parts of the file_path.

But due to the current structure where:

  • value controls both insertion and highlighting,
  • and description is only visual and non-selectable,

you're unable to meet all three goals simultaneously.

I want help in this.

SumitKumar-17 avatar Apr 30 '25 15:04 SumitKumar-17

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.

ysthakur avatar Apr 30 '25 17:04 ysthakur

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.

SumitKumar-17 avatar Apr 30 '25 17:04 SumitKumar-17

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 ?

SumitKumar-17 avatar May 01 '25 08:05 SumitKumar-17

Not with our current menus, I'm afraid. This is being worked on, though.

ysthakur avatar May 05 '25 16:05 ysthakur