Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -774,15 +774,15 @@ namespace Terminal {
notebook.selected_page = tab;
}

if (program.length == 0) {
/* Set up the virtual terminal */
if (location == "") {
terminal_widget.active_shell ();
} else {
terminal_widget.active_shell (location);
}
/* Set up the virtual terminal */
if (location == "") {
terminal_widget.active_shell ();
} else {
terminal_widget.run_program (program, location);
terminal_widget.active_shell (location);
}

if (program.length > 0) {
terminal_widget.run_program (program);
}

save_opened_terminals (true, true);
Expand Down
23 changes: 8 additions & 15 deletions src/Widgets/TerminalWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,13 @@ namespace Terminal {
});
}

// Only used when command launched from command lines
// We do not send SIGINT or reset the shell as we know the shell has only
// just been created and we may need to run e.g. `conda` which sets the environment
public void run_program (string program) {
feed_child ((program + "\n").data);
}

public void change_directory (string path) {
// Ignore if foreground process running, for now.
if (has_foreground_process ()) {
Expand Down Expand Up @@ -748,21 +755,6 @@ namespace Terminal {
}
}

public void run_program (string _program_string, string? working_directory) requires (_program_string.length > 0) {
try {
string[] program_with_args = {};
this.program_string = _program_string;
Shell.parse_argv (program_string, out program_with_args);

this.spawn_sync (Vte.PtyFlags.DEFAULT, working_directory, program_with_args,
null, SpawnFlags.SEARCH_PATH, null, out this.child_pid, null);
} catch (Error e) {
warning (e.message);
feed ((e.message + "\r\n\r\n").data);
active_shell (working_directory);
}
}

public bool try_get_foreground_pid (out int pid) {
if (child_has_exited) {
pid = -1;
Expand Down Expand Up @@ -1002,6 +994,7 @@ namespace Terminal {
if (pid != fg_pid) {
var name = get_pid_exe_name (pid);
foreground_process_changed (name);

fg_pid = pid;
}

Expand Down