Skip to content

Commit f4a1230

Browse files
ximblinry
authored andcommitted
fake-editor: Prefix save message with an "s"
With this, we can distinguish "save" from "close" This fixes issue #160
1 parent 751b3b2 commit f4a1230

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

scenes/text_editor.gd

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ func save():
3838
if text.length() > 0 and text.substr(text.length()-1, 1) != "\n":
3939
text += "\n"
4040

41-
_client_connection.put_string(text)
41+
# Prefix with an 's' to say that this is a "save", not a "close".
42+
_client_connection.put_string("s" + text)
4243

4344
emit_signal("saved")
4445
close()

scripts/fake-editor

+6-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ my $new_content = "";
2828
$socket->recv($new_content, $length);
2929

3030
# Write content back into the file.
31-
my $handle;
32-
open ($handle,'>',$absolute_path) or die("Error opening file");
33-
print $handle $new_content;
34-
close ($handle) or die ("Error closing file");
31+
if ($new_content =~ /^s/) {
32+
my $handle;
33+
open ($handle,'>',$absolute_path) or die("Error opening file");
34+
print $handle (substr $new_content, 1);
35+
close ($handle) or die ("Error closing file");
36+
}
3537

3638
# This call is intended to block, we're waiting for Godot to close the connection.
3739
my $reply;

0 commit comments

Comments
 (0)