Fix task terminal split (#40824)

Kirill Bulatov created

Before:


https://github.com/user-attachments/assets/efe2aeb6-94bb-46b6-944f-5a6345c072b4


After:


https://github.com/user-attachments/assets/61a7f699-6b4d-465f-add1-07774068420c


Release Notes:

- Fixed task terminal split not working correctly

Change summary

crates/project/src/terminals.rs | 6 ++++++
crates/terminal/src/terminal.rs | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)

Detailed changes

crates/project/src/terminals.rs 🔗

@@ -417,6 +417,12 @@ impl Project {
         cx: &mut Context<'_, Project>,
         cwd: Option<PathBuf>,
     ) -> Task<Result<Entity<Terminal>>> {
+        // We cannot clone the task's terminal, as it will effectively re-spawn the task, which might not be desirable.
+        // For now, create a new shell instead.
+        if terminal.read(cx).task().is_some() {
+            return self.create_terminal_shell(cwd, cx);
+        }
+
         let local_path = if self.is_via_remote_server() {
             None
         } else {

crates/terminal/src/terminal.rs 🔗

@@ -454,7 +454,7 @@ impl TerminalBuilder {
                     args: Option<Vec<String>>,
                     title_override: Option<SharedString>,
                 ) -> Self {
-                    log::info!("Using {program} as shell");
+                    log::debug!("Using {program} as shell");
                     Self {
                         program,
                         args,