Merge pull request #7535 from furo321/quote-names

Quote names with spaces when auto completing names in commands.
This commit is contained in:
heinrich5991 2023-11-24 00:06:49 +00:00 committed by GitHub
commit 3fff2f9fc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -393,6 +393,19 @@ bool CChat::OnInput(const IInput::CEvent &Event)
// add part before the name
str_truncate(aBuf, sizeof(aBuf), m_Input.GetString(), m_PlaceholderOffset);
// quote the name
char aQuoted[128];
if(m_Input.GetString()[0] == '/' && (str_find(pCompletionString, " ") || str_find(pCompletionString, "\"")))
{
// escape the name
str_copy(aQuoted, "\"");
char *pDst = aQuoted + str_length(aQuoted);
str_escape(&pDst, pCompletionString, aQuoted + sizeof(aQuoted));
str_append(aQuoted, "\"");
pCompletionString = aQuoted;
}
// add the name
str_append(aBuf, pCompletionString);