Use project environment in LSP runnables context (#29761)

Release Notes:

- Fixed the tasks from LSP not inheriting the worktree environment

----

cc @SomeoneToIgnore
This commit is contained in:
Stanislav Alekseev 2025-05-02 14:01:39 +03:00 committed by GitHub
parent 35539847a4
commit 460ac96df4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 55 additions and 11 deletions

View file

@ -59,8 +59,8 @@ impl ProjectEnvironment {
pub(crate) fn get_buffer_environment(
&mut self,
buffer: Entity<Buffer>,
worktree_store: Entity<WorktreeStore>,
buffer: &Entity<Buffer>,
worktree_store: &Entity<WorktreeStore>,
cx: &mut Context<Self>,
) -> Shared<Task<Option<HashMap<String, String>>>> {
if cfg!(any(test, feature = "test-support")) {

View file

@ -8190,7 +8190,7 @@ impl LspStore {
) -> Shared<Task<Option<HashMap<String, String>>>> {
if let Some(environment) = &self.as_local().map(|local| local.environment.clone()) {
environment.update(cx, |env, cx| {
env.get_buffer_environment(buffer.clone(), self.worktree_store.clone(), cx)
env.get_buffer_environment(&buffer, &self.worktree_store, cx)
})
} else {
Task::ready(None).shared()

View file

@ -56,7 +56,7 @@ use futures::future::join_all;
use futures::{
StreamExt,
channel::mpsc::{self, UnboundedReceiver},
future::try_join_all,
future::{Shared, try_join_all},
};
pub use image_store::{ImageItem, ImageStore};
use image_store::{ImageItemEvent, ImageStoreEvent};
@ -1605,6 +1605,17 @@ impl Project {
self.environment.read(cx).get_cli_environment()
}
pub fn buffer_environment<'a>(
&'a self,
buffer: &Entity<Buffer>,
worktree_store: &Entity<WorktreeStore>,
cx: &'a mut App,
) -> Shared<Task<Option<HashMap<String, String>>>> {
self.environment.update(cx, |environment, cx| {
environment.get_buffer_environment(&buffer, &worktree_store, cx)
})
}
pub fn shell_environment_errors<'a>(
&'a self,
cx: &'a App,

View file

@ -315,11 +315,7 @@ fn local_task_context_for_location(
cx.spawn(async move |cx| {
let project_env = environment
.update(cx, |environment, cx| {
environment.get_buffer_environment(
location.buffer.clone(),
worktree_store.clone(),
cx,
)
environment.get_buffer_environment(&location.buffer, &worktree_store, cx)
})
.ok()?
.await;