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,
|
||||
ViewHandle, WeakViewHandle,
|
||||
};
|
||||
use std::cmp;
|
||||
use std::{cmp, path::Path};
|
||||
|
||||
pub struct FileFinder {
|
||||
handle: WeakViewHandle<Self>,
|
||||
|
@ -139,17 +139,14 @@ impl FileFinder {
|
|||
let tree_id = path_match.tree_id;
|
||||
let entry_id = path_match.entry_id;
|
||||
|
||||
self.worktree(tree_id, app).map(|tree| {
|
||||
let path = tree
|
||||
.path_for_inode(entry_id, path_match.include_root)
|
||||
.unwrap();
|
||||
let file_name = path
|
||||
self.worktree(tree_id, app).map(|_| {
|
||||
let path = &path_match.path;
|
||||
let file_name = Path::new(path)
|
||||
.file_name()
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
|
||||
let path = path.to_string_lossy().to_string();
|
||||
let path_positions = path_match.positions.clone();
|
||||
let file_name_start = path.chars().count() - file_name.chars().count();
|
||||
let mut file_name_positions = Vec::new();
|
||||
|
|
|
@ -45,9 +45,9 @@ impl PathEntry {
|
|||
pub struct PathMatch {
|
||||
pub score: f64,
|
||||
pub positions: Vec<usize>,
|
||||
pub path: String,
|
||||
pub tree_id: usize,
|
||||
pub entry_id: u64,
|
||||
pub include_root: bool,
|
||||
}
|
||||
|
||||
impl PartialEq for PathMatch {
|
||||
|
@ -234,9 +234,9 @@ fn match_single_tree_paths<'a>(
|
|||
results.push(Reverse(PathMatch {
|
||||
tree_id,
|
||||
entry_id: path_entry.ino,
|
||||
path: path_entry.path.iter().skip(skipped_prefix_len).collect(),
|
||||
score,
|
||||
positions: match_positions.clone(),
|
||||
include_root: skipped_prefix_len == 0,
|
||||
}));
|
||||
if results.len() == max_results {
|
||||
*min_score = results.peek().unwrap().0.score;
|
||||
|
|
Loading…
Reference in a new issue