Move code into the platform
Co-Authored-By: Joseph T. Lyons <19867440+JosephTLyons@users.noreply.github.com>
This commit is contained in:
parent
87c1b190a8
commit
a128439699
5 changed files with 44 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::path::Path;
|
||||
|
||||
use fuzzy::StringMatch;
|
||||
use gpui::{
|
||||
|
@ -55,20 +55,17 @@ pub struct HighlightedWorkspaceLocation {
|
|||
}
|
||||
|
||||
impl HighlightedWorkspaceLocation {
|
||||
pub fn new(string_match: &StringMatch, location: &WorkspaceLocation) -> Self {
|
||||
pub fn new(
|
||||
string_match: &StringMatch,
|
||||
location: &WorkspaceLocation,
|
||||
cx: &gpui::AppContext,
|
||||
) -> Self {
|
||||
let mut path_start_offset = 0;
|
||||
let (names, paths): (Vec<_>, Vec<_>) = location
|
||||
.paths()
|
||||
.iter()
|
||||
.map(|path| {
|
||||
let mut full_path = PathBuf::new();
|
||||
if path.starts_with(util::paths::HOME.as_path()) {
|
||||
full_path.push("~");
|
||||
full_path.push(path.strip_prefix(util::paths::HOME.as_path()).unwrap());
|
||||
} else {
|
||||
full_path.push(path)
|
||||
}
|
||||
|
||||
let full_path = cx.platform().convert_to_shortened_path(&path);
|
||||
let highlighted_text = Self::highlights_for_path(
|
||||
full_path.as_ref(),
|
||||
&string_match.positions,
|
||||
|
|
|
@ -192,6 +192,7 @@ impl PickerDelegate for RecentProjectsView {
|
|||
let highlighted_location = HighlightedWorkspaceLocation::new(
|
||||
&string_match,
|
||||
&self.workspace_locations[string_match.candidate_id],
|
||||
&cx,
|
||||
);
|
||||
|
||||
Flex::column()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue