Suggest symbols
Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
parent
219c3bfde8
commit
e2973998ad
2 changed files with 47 additions and 58 deletions
|
@ -44,6 +44,7 @@ impl MentionUri {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo! return something that implements display to avoid extra allocs
|
||||||
pub fn to_link(&self) -> String {
|
pub fn to_link(&self) -> String {
|
||||||
let name = self.name();
|
let name = self.name();
|
||||||
let uri = self.to_uri();
|
let uri = self.to_uri();
|
||||||
|
|
|
@ -161,7 +161,7 @@ fn search(
|
||||||
search_symbols_task
|
search_symbols_task
|
||||||
.await
|
.await
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(Match::Symbol)
|
.map(|symbol| Match::Symbol(symbol))
|
||||||
.collect()
|
.collect()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -621,7 +621,7 @@ impl ContextPickerCompletionProvider {
|
||||||
};
|
};
|
||||||
|
|
||||||
let file_uri = MentionUri::File(abs_path.into());
|
let file_uri = MentionUri::File(abs_path.into());
|
||||||
let new_text = file_uri.to_link();
|
let new_text = format!("{} ", file_uri.to_link());
|
||||||
let new_text_len = new_text.len();
|
let new_text_len = new_text.len();
|
||||||
Some(Completion {
|
Some(Completion {
|
||||||
replace_range: source_range.clone(),
|
replace_range: source_range.clone(),
|
||||||
|
@ -653,65 +653,53 @@ impl ContextPickerCompletionProvider {
|
||||||
workspace: Entity<Workspace>,
|
workspace: Entity<Workspace>,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Option<Completion> {
|
) -> Option<Completion> {
|
||||||
None
|
let path_prefix = workspace
|
||||||
// let path_prefix = workspace
|
.read(cx)
|
||||||
// .read(cx)
|
.project()
|
||||||
// .project()
|
.read(cx)
|
||||||
// .read(cx)
|
.worktree_for_id(symbol.path.worktree_id, cx)?
|
||||||
// .worktree_for_id(symbol.path.worktree_id, cx)?
|
.read(cx)
|
||||||
// .read(cx)
|
.root_name();
|
||||||
// .root_name();
|
|
||||||
|
|
||||||
// let (file_name, directory) =
|
let (file_name, directory) =
|
||||||
// crate::context_picker::file_context_picker::extract_file_name_and_directory(
|
crate::context_picker::file_context_picker::extract_file_name_and_directory(
|
||||||
// &symbol.path.path,
|
&symbol.path.path,
|
||||||
// path_prefix,
|
path_prefix,
|
||||||
// );
|
);
|
||||||
// let full_path = if let Some(directory) = directory {
|
let full_path = if let Some(directory) = directory {
|
||||||
// format!("{}{}", directory, file_name)
|
format!("{}{}", directory, file_name)
|
||||||
// } else {
|
} else {
|
||||||
// file_name.to_string()
|
file_name.to_string()
|
||||||
// };
|
};
|
||||||
|
|
||||||
// let comment_id = cx.theme().syntax().highlight_id("comment").map(HighlightId);
|
let comment_id = cx.theme().syntax().highlight_id("comment").map(HighlightId);
|
||||||
// let mut label = CodeLabel::plain(symbol.name.clone(), None);
|
let mut label = CodeLabel::plain(symbol.name.clone(), None);
|
||||||
// label.push_str(" ", None);
|
label.push_str(" ", None);
|
||||||
// label.push_str(&file_name, comment_id);
|
label.push_str(&file_name, comment_id);
|
||||||
// label.push_str(&format!(" L{}", symbol.range.start.0.row + 1), comment_id);
|
label.push_str(&format!(" L{}", symbol.range.start.0.row + 1), comment_id);
|
||||||
|
|
||||||
// let new_text = MentionUri::Symbol(full_path.into(), symbol.name.clone()).to_link();
|
let uri = MentionUri::Symbol(full_path.into(), symbol.name.clone());
|
||||||
// let new_text_len = new_text.len();
|
let new_text = format!("{} ", uri.to_link());
|
||||||
// Some(Completion {
|
let new_text_len = new_text.len();
|
||||||
// replace_range: source_range.clone(),
|
Some(Completion {
|
||||||
// new_text,
|
replace_range: source_range.clone(),
|
||||||
// label,
|
new_text,
|
||||||
// documentation: None,
|
label,
|
||||||
// source: project::CompletionSource::Custom,
|
documentation: None,
|
||||||
// icon_path: Some(IconName::Code.path().into()),
|
source: project::CompletionSource::Custom,
|
||||||
// insert_text_mode: None,
|
icon_path: Some(IconName::Code.path().into()),
|
||||||
// confirm: Some(confirm_completion_callback(
|
insert_text_mode: None,
|
||||||
// IconName::Code.path().into(),
|
confirm: Some(confirm_completion_callback(
|
||||||
// symbol.name.clone().into(),
|
IconName::Code.path().into(),
|
||||||
// excerpt_id,
|
symbol.name.clone().into(),
|
||||||
// source_range.start,
|
excerpt_id,
|
||||||
// new_text_len - 1,
|
source_range.start,
|
||||||
// editor.clone(),
|
new_text_len - 1,
|
||||||
// context_store.clone(),
|
editor.clone(),
|
||||||
// move |_, cx| {
|
mention_set.clone(),
|
||||||
// let symbol = symbol.clone();
|
uri,
|
||||||
// let context_store = context_store.clone();
|
)),
|
||||||
// let workspace = workspace.clone();
|
})
|
||||||
// let result = crate::context_picker::symbol_context_picker::add_symbol(
|
|
||||||
// symbol.clone(),
|
|
||||||
// false,
|
|
||||||
// workspace.clone(),
|
|
||||||
// context_store.downgrade(),
|
|
||||||
// cx,
|
|
||||||
// );
|
|
||||||
// cx.spawn(async move |_| result.await.log_err()?.0)
|
|
||||||
// },
|
|
||||||
// )),
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue