fix a couple of issues with mention URIs
This commit is contained in:
parent
9fa49b89de
commit
d8131278f1
2 changed files with 19 additions and 24 deletions
|
@ -135,10 +135,12 @@ impl MentionUri {
|
||||||
name,
|
name,
|
||||||
line_range,
|
line_range,
|
||||||
} => {
|
} => {
|
||||||
|
let query = url::form_urlencoded::Serializer::new(String::new())
|
||||||
|
.append_pair("symbol", name)
|
||||||
|
.finish();
|
||||||
format!(
|
format!(
|
||||||
"file://{}?symbol={}#L{}:{}",
|
"file://{}?{query}#L{}:{}",
|
||||||
path.display(),
|
path.display(),
|
||||||
name,
|
|
||||||
line_range.start + 1,
|
line_range.start + 1,
|
||||||
line_range.end + 1,
|
line_range.end + 1,
|
||||||
)
|
)
|
||||||
|
@ -152,13 +154,22 @@ impl MentionUri {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
MentionUri::Thread { name, id } => {
|
MentionUri::Thread { name, id } => {
|
||||||
format!("zed:///agent/thread/{id}?name={name}")
|
let query = url::form_urlencoded::Serializer::new(String::new())
|
||||||
|
.append_pair("name", name)
|
||||||
|
.finish();
|
||||||
|
format!("zed:///agent/thread/{id}?{query}")
|
||||||
}
|
}
|
||||||
MentionUri::TextThread { path, name } => {
|
MentionUri::TextThread { path, name } => {
|
||||||
format!("zed:///agent/text-thread/{}?name={name}", path.display())
|
let query = url::form_urlencoded::Serializer::new(String::new())
|
||||||
|
.append_pair("name", name)
|
||||||
|
.finish();
|
||||||
|
format!("zed:///agent/text-thread/{}?{query}", path.display())
|
||||||
}
|
}
|
||||||
MentionUri::Rule { name, id } => {
|
MentionUri::Rule { name, id } => {
|
||||||
format!("zed:///agent/rule/{id}?name={name}")
|
let query = url::form_urlencoded::Serializer::new(String::new())
|
||||||
|
.append_pair("name", name)
|
||||||
|
.finish();
|
||||||
|
format!("zed:///agent/rule/{id}?{query}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -688,29 +688,13 @@ impl ContextPickerCompletionProvider {
|
||||||
workspace: Entity<Workspace>,
|
workspace: Entity<Workspace>,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Option<Completion> {
|
) -> Option<Completion> {
|
||||||
let path_prefix = workspace
|
let project = workspace.read(cx).project().clone();
|
||||||
.read(cx)
|
|
||||||
.project()
|
|
||||||
.read(cx)
|
|
||||||
.worktree_for_id(symbol.path.worktree_id, cx)?
|
|
||||||
.read(cx)
|
|
||||||
.root_name();
|
|
||||||
|
|
||||||
let (file_name, directory) =
|
|
||||||
crate::context_picker::file_context_picker::extract_file_name_and_directory(
|
|
||||||
&symbol.path.path,
|
|
||||||
path_prefix,
|
|
||||||
);
|
|
||||||
let full_path = if let Some(directory) = directory {
|
|
||||||
format!("{}{}", directory, file_name)
|
|
||||||
} else {
|
|
||||||
file_name.to_string()
|
|
||||||
};
|
|
||||||
|
|
||||||
let label = CodeLabel::plain(symbol.name.clone(), None);
|
let label = CodeLabel::plain(symbol.name.clone(), None);
|
||||||
|
|
||||||
|
let abs_path = project.read(cx).absolute_path(&symbol.path, cx)?;
|
||||||
let uri = MentionUri::Symbol {
|
let uri = MentionUri::Symbol {
|
||||||
path: full_path.into(),
|
path: abs_path,
|
||||||
name: symbol.name.clone(),
|
name: symbol.name.clone(),
|
||||||
line_range: symbol.range.start.0.row..symbol.range.end.0.row,
|
line_range: symbol.range.start.0.row..symbol.range.end.0.row,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue