Skip to content

Commit 9f944d5

Browse files
committed
Fixed bug where joined lists of string values are joined with extra quotes
1 parent ff6e0f8 commit 9f944d5

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

EasyCommands.Tests/ScriptTests/FunctionalTests/Operations/SimpleJoinTests.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ public void JoinKeyedList() {
2323

2424
test.RunOnce();
2525

26-
Assert.AreEqual("one->1, two->2, three->3", test.Logger[0]);
26+
Assert.AreEqual("1, 2, 3", test.Logger[0]);
27+
}
28+
}
29+
30+
[TestMethod]
31+
public void JoinListOfSpacedStrings() {
32+
using (var test = new ScriptTest(@"print [""string one"", ""string two"", ""string three""] joined "", """)) {
33+
test.MockNextBoundedRandoms(10, 6);
34+
35+
test.RunOnce();
36+
37+
Assert.AreEqual("string one, string two, string three", test.Logger[0]);
2738
}
2839
}
2940

EasyCommands/Common/Operations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void InitializeOperators() {
136136
AddBiOperation<string, string>(BiOperand.MOD, (a, b) => a.Replace(b, ""));
137137
AddBiOperation<string, float>(BiOperand.SUBTRACT, (a, b) => b >= a.Length ? "" : a.Substring(0, (int)(a.Length - b)));
138138
AddBiOperation<object, string>(BiOperand.CAST, (a, b) => castMap[b](ResolvePrimitive(a)));
139-
AddBiOperation<KeyedList, string>(BiOperand.JOIN, (a, b) => string.Join(CastString(ResolvePrimitive(b)), a.keyedValues.Select(v => v.Print())));
139+
AddBiOperation<KeyedList, string>(BiOperand.JOIN, (a, b) => string.Join(CastString(ResolvePrimitive(b)), a.keyedValues.Select(v => CastString(v.GetValue()))));
140140

141141
//Vector
142142
AddUniOperation<Vector3D>(UniOperand.SIGN, a => Vector3D.Sign(a));

docs/EasyCommands/operations.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ Keywords: ```^, pow, xor```
465465
* **(Vector, Vector)**: Returns the angle (in degrees) between the two given vectors (get it? ```^```)
466466

467467
### Join
468-
Joins a given list by the given string separator by casting each list value to a string and then joining them together using the given separator.
468+
Joins a given list by the given string separator by casting each list value to a string and then joining them together using the given separator. When joining values the keys are stripped. Only the values get joined.
469469

470470
Keywords: ```join, joined```
471471

@@ -477,6 +477,17 @@ set myOutput to [1,2,3] joined ", "
477477
```
478478
#Line Separated Values
479479
set myOutput to [1,2,3] joined "\n"
480+
print myOutput
481+
#1
482+
#2
483+
#3
484+
```
485+
486+
```
487+
#Keys are stripped
488+
set myOutput to ["one" -> 1, "two" -> 2, "three" -> 3] joined ", "
489+
print myOutput
490+
#1, 2, 3
480491
```
481492

482493
### Modulus

0 commit comments

Comments
 (0)