From 3270bb64d0d846046187569939b590fdc04738a4 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Tue, 29 Sep 2020 18:36:24 +0200 Subject: [PATCH] Fix a problem where the global_shell was in a non-existing directory --- helpers.gd | 1 + sandbox.gd | 2 +- sandbox.tscn | 8 ++++---- shell.gd | 4 ++-- terminal.gd | 2 +- text_editor.gd | 4 ++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/helpers.gd b/helpers.gd index d5d9a27..3b9b341 100644 --- a/helpers.gd +++ b/helpers.gd @@ -82,4 +82,5 @@ func careful_delete(path_inside): if path_inside.substr(0,expected_prefix.length()) != expected_prefix: helpers.crash("Refusing to delete directory %s that does not start with %s" % [path_inside, expected_prefix]) else: + game.global_shell.cd(game.tmp_prefix_inside) game.global_shell.run("rm -rf '%s'" % path_inside) diff --git a/sandbox.gd b/sandbox.gd index b289fa0..b06fca3 100644 --- a/sandbox.gd +++ b/sandbox.gd @@ -23,6 +23,6 @@ func _ready(): game.global_shell.run("git init") game.global_shell.run("git symbolic-ref HEAD refs/heads/main") - $HSplitContainer/Repository.path = path + $Columns/Repository.path = path get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_2D, SceneTree.STRETCH_ASPECT_KEEP, Vector2(1920, 1080), 1.5) diff --git a/sandbox.tscn b/sandbox.tscn index 7132750..f8df3bf 100644 --- a/sandbox.tscn +++ b/sandbox.tscn @@ -23,7 +23,7 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="HSplitContainer" type="HSplitContainer" parent="."] +[node name="Columns" type="HSplitContainer" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 margin_left = 5.0 @@ -34,7 +34,7 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="Repository" parent="HSplitContainer" instance=ExtResource( 2 )] +[node name="Repository" parent="Columns" instance=ExtResource( 2 )] anchor_right = 0.0 anchor_bottom = 0.0 margin_right = 949.0 @@ -42,11 +42,11 @@ margin_bottom = 1070.0 size_flags_horizontal = 3 editable_path = true -[node name="Terminal" parent="HSplitContainer" instance=ExtResource( 1 )] +[node name="Terminal" parent="Columns" instance=ExtResource( 1 )] anchor_right = 0.0 anchor_bottom = 0.0 margin_left = 961.0 margin_right = 1910.0 margin_bottom = 1070.0 size_flags_horizontal = 3 -repository_path = NodePath("../Repository") +repository_path = NodePath("../../Columns/Repository") diff --git a/shell.gd b/shell.gd index 6ed7fd8..f839109 100644 --- a/shell.gd +++ b/shell.gd @@ -13,7 +13,7 @@ func cd(dir): # Run a shell command given as a string. Run this if you're interested in the # output of the command. -func run(command): +func run(command, crash_on_fail=true): var debug = false if debug: @@ -49,7 +49,7 @@ func run(command): # hacky_command = '"\''+hacky_command.replace("'", "'\"'\"'")+'\'"' - var output = helpers.exec(_shell_binary(), ["-c", hacky_command], false) + var output = helpers.exec(_shell_binary(), ["-c", hacky_command], crash_on_fail) if debug: print(output) diff --git a/terminal.gd b/terminal.gd index 71359b6..8e97fdc 100644 --- a/terminal.gd +++ b/terminal.gd @@ -93,7 +93,7 @@ func send_command_async(command): $TCPServer.send(command+"\n") func run_command_in_a_thread(command): - var o = repository.shell.run(command) + var o = repository.shell.run(command, false) check_win_condition() input.text = "" diff --git a/text_editor.gd b/text_editor.gd index 7740cdc..3cfc830 100644 --- a/text_editor.gd +++ b/text_editor.gd @@ -21,7 +21,7 @@ func _process(_delta): func open(filename): path = filename - var fixme_path = game.tmp_prefix_outside+"/active/" + var fixme_path = game.tmp_prefix_outside+"/repos/active/" var content = helpers.read_file(fixme_path+filename) text = content @@ -29,7 +29,7 @@ func open(filename): grab_focus() func save(): - var fixme_path = game.tmp_prefix_outside+"/active/" + var fixme_path = game.tmp_prefix_outside+"/repos/active/" helpers.write_file(fixme_path+path, text) close()