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

Picker fuzzy highlighting is offset when using more than one column #6254

Closed
lazytanuki opened this issue Mar 10, 2023 · 0 comments · Fixed by #6333
Closed

Picker fuzzy highlighting is offset when using more than one column #6254

lazytanuki opened this issue Mar 10, 2023 · 0 comments · Fixed by #6333
Labels
C-bug Category: This is a bug

Comments

@lazytanuki
Copy link
Contributor

Summary

In pickers that use more than one column (such as the buffer picker, then only one for now I think), the highlight of the fuzzy matching is offset from the second column.

image

Discovered this issue when working on #2869 .

In helix-term/src/ui/picker.rs:218, I noticed that, in the following code, for each span the grapheme_byte_offset is reset to 0.

let graphemes_with_style: Vec<_> = spans
    .0
    .iter()
    .flat_map(|span| {
        span.content
            .grapheme_indices(true)
            .zip(std::iter::repeat(span.style))
    })
    .map(|((grapheme_byte_offset, grapheme), style)| {
        cell_len += grapheme.len();
        let start = cell_start_byte_offset;

        let grapheme_byte_range =
            grapheme_byte_offset..grapheme_byte_offset + grapheme.len();

        if highlight_byte_ranges.iter().any(|hl_rng| {
            hl_rng.start >= start + grapheme_byte_range.start
                && hl_rng.end <= start + grapheme_byte_range.end
        }) {
            (grapheme, style.patch(highlight_style))
        } else {
            (grapheme, style)
        }
    })
    .collect();

This may be the source of the offset we see.

Reproduction Steps

  1. open the buffer picker
  2. type in some chars and see the highlighted portion of the line

Helix log

This issue is not visible in the logs.

Platform

Linux

Terminal Emulator

Kitty

Helix Version

master build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant