Skip to content

Commit 1ff95a7

Browse files
authored
Merge pull request #50 from bfrymire/prevent-running-empty-commands
Fix empty commands from executing
2 parents 14bd6e9 + 9f1faf6 commit 1ff95a7

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

rt-shell/objects/obj_shell/Step_0.gml

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -150,35 +150,42 @@ if (!isOpen) {
150150
}
151151
targetScrollPosition = maxScrollPosition;
152152
} else if (keyboard_check_pressed(vk_enter)) {
153-
if (isAutocompleteOpen) {
154-
self._confirm_current_suggestion();
155-
} else {
156-
var args = self._input_string_split(consoleString);
157-
if (array_length(args) > 0) {
158-
var metadata = functionData[$ args[0]];
159-
if (!is_undefined(metadata)) {
160-
var deferred = false;
161-
if (variable_struct_exists(metadata, "deferred")) {
162-
deferred = metadata.deferred;
163-
}
164-
if (deferred) {
165-
ds_queue_enqueue(deferredQueue, args);
166-
array_push(history, consoleString);
167-
array_push(output, ">" + consoleString);
168-
array_push(output, "Execution deferred until shell is closed.");
169-
self._update_positions();
153+
if (string_trim(consoleString) != "") {
154+
if (isAutocompleteOpen) {
155+
self._confirm_current_suggestion();
156+
} else {
157+
var args = self._input_string_split(consoleString);
158+
if (array_length(args) > 0) {
159+
var metadata = functionData[$ args[0]];
160+
if (!is_undefined(metadata)) {
161+
var deferred = false;
162+
if (variable_struct_exists(metadata, "deferred")) {
163+
deferred = metadata.deferred;
164+
}
165+
if (deferred) {
166+
ds_queue_enqueue(deferredQueue, args);
167+
array_push(history, consoleString);
168+
array_push(output, ">" + consoleString);
169+
array_push(output, "Execution deferred until shell is closed.");
170+
self._update_positions();
171+
} else {
172+
_execute_script(args);
173+
}
170174
} else {
171175
_execute_script(args);
172176
}
173177
} else {
174-
_execute_script(args);
178+
array_push(output, ">");
179+
consoleString = "";
180+
savedConsoleString = "";
181+
cursorPos = 1;
175182
}
176-
} else {
177-
array_push(output, ">");
178-
consoleString = "";
179-
savedConsoleString = "";
180-
cursorPos = 1;
181183
}
184+
} else {
185+
array_push(output, ">");
186+
consoleString = "";
187+
savedConsoleString = "";
188+
cursorPos = 1;
182189
}
183190
commandSubmitted = true;
184191
} else if (self._key_combo_pressed(cycleSuggestionsModifiers, cycleSuggestionsKey) || keyboard_check_pressed(vk_down)) {

0 commit comments

Comments
 (0)