Skip to content

Commit ed3af9a

Browse files
committed
Fix commas in adding input to pyodide. Change loop to break from it.
1 parent dbb19c6 commit ed3af9a

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/pages/New.vue

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@
2020
<template slot="label">
2121
<span class="has-text-white">Code</span>
2222
</template>
23-
<codemirror v-model="codeL" class="codemirror" :options="cmOption" />
23+
<codemirror
24+
v-model="codeL"
25+
class="codemirror"
26+
:options="cmOption"
27+
/>
2428
</b-field>
2529
<b-field>
2630
<template slot="label">
2731
<span class="has-text-white">Output</span>
2832
</template>
2933
<textarea class="textarea" v-model="outputL" readonly rows="4" />
3034
</b-field>
31-
<b-button type="button is-primary" @click="updateList">Save</b-button>
35+
<b-button type="button is-primary" @click="updateList"
36+
>Save</b-button
37+
>
3238
<b-button type="button" @click="runCode()" outlined>Run</b-button>
3339
</div>
3440
</div>
@@ -185,21 +191,28 @@ export default {
185191
// bad way to see if multiple lines - fix if possible
186192
else if (this.inputL.includes("\n")) {
187193
var newArr = "[";
188-
189-
this.inputL.split("\n").forEach(function(element) {
190-
var inp = this.typeString(element);
191-
194+
var splitArr = this.inputL.split("\n");
195+
for (let i = 0; i < splitArr.length; i++) {
196+
var inp = this.typeString(splitArr[i]);
192197
if (inp == null) {
193198
return null;
194199
} else if (
195200
// check if string
196201
this.isString(inp)
197202
) {
198-
newArr = newArr + "'" + inp + "',";
203+
if (i == splitArr.length - 1) {
204+
newArr = newArr + "'" + inp + "'";
205+
} else {
206+
newArr = newArr + "'" + inp + "',";
207+
}
199208
} else {
200-
newArr = newArr + inp + ",";
209+
if (i == splitArr.length - 1) {
210+
newArr = newArr + inp;
211+
} else {
212+
newArr = newArr + inp + ",";
213+
}
201214
}
202-
});
215+
}
203216
newArr = newArr + "]";
204217
return newArr;
205218
} else {

0 commit comments

Comments
 (0)