Set the working directory according to the editor file path (#14688)

Kernels now launch in the same directory as the script invoking them,
similar to notebook behavior.


![image](https://github.com/user-attachments/assets/def86308-bea4-4fa3-8211-132a282a5ecc)


Release Notes:

- N/A
This commit is contained in:
Kyle Kelley 2024-07-17 15:37:47 -07:00 committed by GitHub
parent f5f4578422
commit ba4fa17b83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 52 additions and 17 deletions

View file

@ -171,6 +171,7 @@ pub struct RunningKernel {
_control_task: Task<anyhow::Result<()>>,
_routing_task: Task<anyhow::Result<()>>,
connection_path: PathBuf,
pub working_directory: PathBuf,
pub request_tx: mpsc::Sender<JupyterMessage>,
pub execution_state: ExecutionState,
pub kernel_info: Option<KernelInfoReply>,
@ -190,6 +191,7 @@ impl RunningKernel {
pub fn new(
kernel_specification: KernelSpecification,
entity_id: EntityId,
working_directory: PathBuf,
fs: Arc<dyn Fs>,
cx: &mut AppContext,
) -> Task<anyhow::Result<(Self, JupyterMessageChannel)>> {
@ -220,7 +222,9 @@ impl RunningKernel {
fs.atomic_write(connection_path.clone(), content).await?;
let mut cmd = kernel_specification.command(&connection_path)?;
let process = cmd
.current_dir(&working_directory)
// .stdout(Stdio::null())
// .stderr(Stdio::null())
.kill_on_drop(true)
@ -301,6 +305,7 @@ impl RunningKernel {
Self {
process,
request_tx,
working_directory,
_shell_task,
_iopub_task,
_control_task,