Skip to content

Commit 038808e

Browse files
committed
Fix problem with automatic space insertion for negative number arguments
1 parent f96b716 commit 038808e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Source/Objects/TextObject.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,14 @@ struct TextObjectHelper {
9999
static String fixMissingSpace(String text)
100100
{
101101
static const String operatorChars = "+-*/% <=>!|&~";
102+
auto toCheck = text.upToFirstOccurrenceOf(" ", false, false);
102103

103104
int opEnd = 0;
104-
while (opEnd < text.length() && operatorChars.containsChar(text[opEnd]))
105+
while (opEnd < toCheck.length() && operatorChars.containsChar(toCheck[opEnd]))
105106
opEnd++;
106107

107-
if (opEnd > 0 && opEnd < text.length() && text.substring(opEnd).containsOnly("0123456789"))
108-
return text.substring(0, opEnd) + " " + text.substring(opEnd);
108+
if (opEnd > 0 && opEnd < toCheck.length() && toCheck.substring(opEnd).containsOnly("0123456789"))
109+
return toCheck.substring(0, opEnd) + " " + text.substring(opEnd);
109110

110111
return text;
111112
}

0 commit comments

Comments
 (0)