Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
This commit is contained in:
Piotr Osiewicz 2025-02-28 18:33:35 +01:00 committed by GitHub
parent fc52b43159
commit e4e758db3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
68 changed files with 180 additions and 190 deletions

View file

@ -1451,9 +1451,9 @@ impl<'a> PathComponentSlice<'a> {
matches.next();
}
if is_first_normal || is_last || !is_normal || contains_match {
if !longest
if longest
.as_ref()
.is_some_and(|old| old.end - old.start > cur.end - cur.start)
.is_none_or(|old| old.end - old.start <= cur.end - cur.start)
{
longest = Some(cur);
}
@ -1462,9 +1462,9 @@ impl<'a> PathComponentSlice<'a> {
cur.end = i + 1;
}
}
if !longest
if longest
.as_ref()
.is_some_and(|old| old.end - old.start > cur.end - cur.start)
.is_none_or(|old| old.end - old.start <= cur.end - cur.start)
{
longest = Some(cur);
}

View file

@ -108,7 +108,7 @@ impl Match {
fn styled_text(&self, project: &Project, window: &Window, cx: &App) -> StyledText {
let mut text = "./".to_string();
let mut highlights = Vec::new();
let mut offset = text.as_bytes().len();
let mut offset = text.len();
let separator = '/';
let dir_indicator = "[…]";
@ -125,7 +125,7 @@ impl Match {
highlights.push((range.start + offset..range.end + offset, style))
}
text.push(separator);
offset = text.as_bytes().len();
offset = text.len();
if let Some(suffix) = &self.suffix {
text.push_str(suffix);
@ -140,10 +140,10 @@ impl Match {
Color::Created
};
highlights.push((
offset..offset + suffix.as_bytes().len(),
offset..offset + suffix.len(),
HighlightStyle::color(color.color(cx)),
));
offset += suffix.as_bytes().len();
offset += suffix.len();
if entry.is_some_and(|e| e.is_dir()) {
text.push(separator);
offset += separator.len_utf8();
@ -165,7 +165,7 @@ impl Match {
text.push_str(suffix);
let existing_prefix_len = self
.existing_prefix(project, cx)
.map(|prefix| prefix.to_string_lossy().as_bytes().len())
.map(|prefix| prefix.to_string_lossy().len())
.unwrap_or(0);
if existing_prefix_len > 0 {
@ -175,14 +175,14 @@ impl Match {
));
}
highlights.push((
offset + existing_prefix_len..offset + suffix.as_bytes().len(),
offset + existing_prefix_len..offset + suffix.len(),
HighlightStyle::color(if self.entry(project, cx).is_some() {
Color::Conflict.color(cx)
} else {
Color::Created.color(cx)
}),
));
offset += suffix.as_bytes().len();
offset += suffix.len();
if suffix.ends_with('/') {
text.push_str(dir_indicator);
highlights.push((