From 023944bd8fac0b594a2a4e36666f053babae4932 Mon Sep 17 00:00:00 2001 From: Sasial <44125644+sasial-dev@users.noreply.github.com> Date: Sun, 11 Feb 2024 14:41:22 +1000 Subject: [PATCH] feat(autocomplete): add quotes around an argument if it has spaces --- .../interface/components/terminal/TerminalTextField.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client/interface/components/terminal/TerminalTextField.tsx b/src/client/interface/components/terminal/TerminalTextField.tsx index 11692f78..c27e1c7f 100644 --- a/src/client/interface/components/terminal/TerminalTextField.tsx +++ b/src/client/interface/components/terminal/TerminalTextField.tsx @@ -200,7 +200,13 @@ export function TerminalTextField({ newText = newText.sub(0, newText.size() - parts[parts.size() - 1].size()); } - newText += currentSuggestion.others[0]; + let suggestion = currentSuggestion.others[0]; + + if (string.match(suggestion, "%s")[0] !== undefined) { + suggestion = `"${suggestion}"`; + } + + newText += suggestion; if (argIndex < commandArgs.size() - 1) { newText += " "; }