mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-28 01:07:09 +00:00
Store paths as strings on PathMatch structs
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
955268e2a6
commit
8e0ca2056e
2 changed files with 6 additions and 9 deletions
|
@ -14,7 +14,7 @@ use gpui::{
|
||||||
AppContext, Axis, Border, Entity, ModelHandle, MutableAppContext, View, ViewContext,
|
AppContext, Axis, Border, Entity, ModelHandle, MutableAppContext, View, ViewContext,
|
||||||
ViewHandle, WeakViewHandle,
|
ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use std::cmp;
|
use std::{cmp, path::Path};
|
||||||
|
|
||||||
pub struct FileFinder {
|
pub struct FileFinder {
|
||||||
handle: WeakViewHandle<Self>,
|
handle: WeakViewHandle<Self>,
|
||||||
|
@ -139,17 +139,14 @@ impl FileFinder {
|
||||||
let tree_id = path_match.tree_id;
|
let tree_id = path_match.tree_id;
|
||||||
let entry_id = path_match.entry_id;
|
let entry_id = path_match.entry_id;
|
||||||
|
|
||||||
self.worktree(tree_id, app).map(|tree| {
|
self.worktree(tree_id, app).map(|_| {
|
||||||
let path = tree
|
let path = &path_match.path;
|
||||||
.path_for_inode(entry_id, path_match.include_root)
|
let file_name = Path::new(path)
|
||||||
.unwrap();
|
|
||||||
let file_name = path
|
|
||||||
.file_name()
|
.file_name()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
let path = path.to_string_lossy().to_string();
|
|
||||||
let path_positions = path_match.positions.clone();
|
let path_positions = path_match.positions.clone();
|
||||||
let file_name_start = path.chars().count() - file_name.chars().count();
|
let file_name_start = path.chars().count() - file_name.chars().count();
|
||||||
let mut file_name_positions = Vec::new();
|
let mut file_name_positions = Vec::new();
|
||||||
|
|
|
@ -45,9 +45,9 @@ impl PathEntry {
|
||||||
pub struct PathMatch {
|
pub struct PathMatch {
|
||||||
pub score: f64,
|
pub score: f64,
|
||||||
pub positions: Vec<usize>,
|
pub positions: Vec<usize>,
|
||||||
|
pub path: String,
|
||||||
pub tree_id: usize,
|
pub tree_id: usize,
|
||||||
pub entry_id: u64,
|
pub entry_id: u64,
|
||||||
pub include_root: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for PathMatch {
|
impl PartialEq for PathMatch {
|
||||||
|
@ -234,9 +234,9 @@ fn match_single_tree_paths<'a>(
|
||||||
results.push(Reverse(PathMatch {
|
results.push(Reverse(PathMatch {
|
||||||
tree_id,
|
tree_id,
|
||||||
entry_id: path_entry.ino,
|
entry_id: path_entry.ino,
|
||||||
|
path: path_entry.path.iter().skip(skipped_prefix_len).collect(),
|
||||||
score,
|
score,
|
||||||
positions: match_positions.clone(),
|
positions: match_positions.clone(),
|
||||||
include_root: skipped_prefix_len == 0,
|
|
||||||
}));
|
}));
|
||||||
if results.len() == max_results {
|
if results.len() == max_results {
|
||||||
*min_score = results.peek().unwrap().0.score;
|
*min_score = results.peek().unwrap().0.score;
|
||||||
|
|
Loading…
Reference in a new issue