From 5fd0057aee5ffb8f67c010aefa5dce217447e494 Mon Sep 17 00:00:00 2001 From: Sasial <44125644+sasial-dev@users.noreply.github.com> Date: Sun, 11 Feb 2024 14:39:17 +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..49bce8ba 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 += " "; }