diff --git a/src/Widgets/Terminal.vala b/src/Widgets/Terminal.vala index 1a2202eb2..ee28946f3 100644 --- a/src/Widgets/Terminal.vala +++ b/src/Widgets/Terminal.vala @@ -44,7 +44,13 @@ public class Code.Terminal : Gtk.Box { } terminal.child_exited.connect (() => { - GLib.Application.get_default ().activate_action (Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_TOGGLE_TERMINAL, null); + //Hide the exited terminal + var win_group = get_action_group (Scratch.MainWindow.ACTION_GROUP); + win_group.activate_action (Scratch.MainWindow.ACTION_TOGGLE_TERMINAL, null); + //Get ready to resume at last saved location + spawn_shell (Scratch.saved_state.get_string ("last-opened-path")); + //Clear screen of new shell + terminal.feed_child ("clear -x\n".data); }); var copy_action = new SimpleAction (ACTION_COPY, null); @@ -89,8 +95,7 @@ public class Code.Terminal : Gtk.Box { copy_action.set_enabled (terminal.get_has_selection ()); }); - var settings = new Settings (Constants.PROJECT_NAME + ".saved-state"); - spawn_shell (settings.get_string ("last-opened-path")); + spawn_shell (Scratch.saved_state.get_string ("last-opened-path")); var scrolled_window = new Gtk.ScrolledWindow (null, terminal.get_vadjustment ()); scrolled_window.add (terminal); @@ -98,7 +103,7 @@ public class Code.Terminal : Gtk.Box { add (scrolled_window); destroy.connect (() => { - settings.set_string ("last-opened-path", get_shell_location ()); + Scratch.saved_state.set_string ("last-opened-path", get_shell_location ()); }); show_all (); @@ -125,6 +130,7 @@ public class Code.Terminal : Gtk.Box { Posix.kill (child_pid, Posix.Signal.TERM); terminal.reset (true, true); spawn_shell (dir); + Scratch.saved_state.set_string ("last-opened-path", dir); } private string get_shell_location () {