From 38675f94e83ae7e2600ecf902febcd7051edcbd4 Mon Sep 17 00:00:00 2001 From: Morten Minde Neergaard <169057+xim@users.noreply.github.com> Date: Thu, 3 Nov 2022 08:41:40 +0100 Subject: [PATCH] fake-editor: Prefix save message with an "s" With this, we can distinguish "save" from "close" This fixes issue #160 --- scenes/text_editor.gd | 2 +- scripts/fake-editor | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/scenes/text_editor.gd b/scenes/text_editor.gd index 2018eec..59efeac 100644 --- a/scenes/text_editor.gd +++ b/scenes/text_editor.gd @@ -38,7 +38,7 @@ func save(): if text.length() > 0 and text.substr(text.length()-1, 1) != "\n": text += "\n" - _client_connection.put_string(text) + _client_connection.put_string("s" + text) emit_signal("saved") close() diff --git a/scripts/fake-editor b/scripts/fake-editor index 690694d..044a01c 100755 --- a/scripts/fake-editor +++ b/scripts/fake-editor @@ -28,10 +28,12 @@ my $new_content = ""; $socket->recv($new_content, $length); # Write content back into the file. -my $handle; -open ($handle,'>',$absolute_path) or die("Error opening file"); -print $handle $new_content; -close ($handle) or die ("Error closing file"); +if ($new_content =~ /^s/) { + my $handle; + open ($handle,'>',$absolute_path) or die("Error opening file"); + print $handle (substr $new_content, 1); + close ($handle) or die ("Error closing file"); +} # This call is intended to block, we're waiting for Godot to close the connection. my $reply;