Skip to content

Commit

Permalink
Improve retaining case when autocompleting text in console
Browse files Browse the repository at this point in the history
  • Loading branch information
bradharding committed Nov 4, 2023
1 parent 087ffec commit d44ff79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/c_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,14 @@ bool C_Responder(event_t *ev)
|| (spaces1 == 2 && !endspace1 && (spaces2 == 2 || (spaces2 == 3 && endspace2)))
|| (spaces1 == 3 && !endspace1)))
{
char *temp = M_StringJoin(prefix, M_StringReplaceFirst(output, input, input), NULL);
char *temp;

if (isuppercase(input))
temp = M_StringJoin(prefix, M_StringReplaceFirst(uppercase(output), input, input), NULL);
else if (islowercase(input))
temp = M_StringJoin(prefix, M_StringReplaceFirst(lowercase(output), input, input), NULL);
else
temp = M_StringJoin(prefix, M_StringReplaceFirst(output, input, input), NULL);

C_AddToUndoHistory();
M_StringCopy(consoleinput, temp, sizeof(consoleinput));
Expand Down
8 changes: 4 additions & 4 deletions src/m_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,8 @@ bool isuppercase(const char *str)
{
const int len = (int)strlen(str);

for (int i = 1; i < len; i++)
if (islower(str[i]))
for (int i = 0; i < len; i++)
if (!isupper(str[i]))
return false;

return true;
Expand All @@ -722,8 +722,8 @@ bool islowercase(const char *str)
{
const int len = (int)strlen(str);

for (int i = 1; i < len; i++)
if (isupper(str[i]))
for (int i = 0; i < len; i++)
if (!islower(str[i]))
return false;

return true;
Expand Down

0 comments on commit d44ff79

Please sign in to comment.