Merge Zed task context providing logic (#10544)
Before, `tasks_ui` set most of the context with `SymbolContextProvider` providing the symbol data part of the context. Now, there's a `BasicContextProvider` that forms all standard Zed context and it automatically serves as a base, with no need for other providers like `RustContextProvider` to call it as before. Also, stop adding `SelectedText` task variable into the context for blank text selection. Release Notes: - N/A
This commit is contained in:
parent
97c5cffbe3
commit
573ba83034
5 changed files with 173 additions and 124 deletions
|
@ -331,25 +331,26 @@ const RUST_PACKAGE_TASK_VARIABLE: VariableName =
|
|||
impl ContextProvider for RustContextProvider {
|
||||
fn build_context(
|
||||
&self,
|
||||
location: Location,
|
||||
_: Option<&Path>,
|
||||
location: &Location,
|
||||
cx: &mut gpui::AppContext,
|
||||
) -> Result<TaskVariables> {
|
||||
let mut context = SymbolContextProvider.build_context(location.clone(), cx)?;
|
||||
|
||||
let local_abs_path = location
|
||||
.buffer
|
||||
.read(cx)
|
||||
.file()
|
||||
.and_then(|file| Some(file.as_local()?.abs_path(cx)));
|
||||
if let Some(package_name) = local_abs_path
|
||||
.as_deref()
|
||||
.and_then(|local_abs_path| local_abs_path.parent())
|
||||
.and_then(human_readable_package_name)
|
||||
{
|
||||
context.insert(RUST_PACKAGE_TASK_VARIABLE.clone(), package_name);
|
||||
}
|
||||
|
||||
Ok(context)
|
||||
Ok(
|
||||
if let Some(package_name) = local_abs_path
|
||||
.as_deref()
|
||||
.and_then(|local_abs_path| local_abs_path.parent())
|
||||
.and_then(human_readable_package_name)
|
||||
{
|
||||
TaskVariables::from_iter(Some((RUST_PACKAGE_TASK_VARIABLE.clone(), package_name)))
|
||||
} else {
|
||||
TaskVariables::default()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn associated_tasks(&self) -> Option<TaskTemplates> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue