@vnejs/plugins.feature.choose 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/modules/choose.js +1 -1
- package/modules/scenario.js +3 -5
- package/package.json +1 -1
package/modules/choose.js
CHANGED
|
@@ -51,7 +51,7 @@ export class Choose extends Module {
|
|
|
51
51
|
getOptionText = (line) => {
|
|
52
52
|
const quotedText = line.slice(line.indexOf('"'), line.lastIndexOf('"') + 1);
|
|
53
53
|
|
|
54
|
-
return this.emitOne(this.EVENTS.
|
|
54
|
+
return this.emitOne(this.EVENTS.TEXT.REPLACE, { text: quotedText.slice(1, quotedText.length - 1), label: this.globalState.scenario.label });
|
|
55
55
|
};
|
|
56
56
|
getOptionCoords = (line) => {
|
|
57
57
|
const lineText = line.slice("% option ".length);
|
package/modules/scenario.js
CHANGED
|
@@ -5,20 +5,18 @@ export class ChooseScenario extends Module {
|
|
|
5
5
|
|
|
6
6
|
execName = "choose";
|
|
7
7
|
|
|
8
|
-
init = () => this.emit(this.EVENTS.SCENARIO.
|
|
8
|
+
init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { block: this.execName, handler: this.execHandler });
|
|
9
9
|
|
|
10
10
|
execHandler = async (line, args) => {
|
|
11
11
|
const { curLine = 0, label } = this.globalState.scenario;
|
|
12
|
-
const
|
|
12
|
+
const lines = await this.emitOne(this.EVENTS.SCENARIO.LINES_GET, { label });
|
|
13
13
|
const optionsArr = [];
|
|
14
14
|
|
|
15
15
|
let indexShift = 1;
|
|
16
16
|
let curLineObj = lines[curLine + indexShift];
|
|
17
17
|
|
|
18
18
|
while (curLineObj && curLineObj.indent >= lines[curLine].indent) {
|
|
19
|
-
curLineObj.line.startsWith("% option") &&
|
|
20
|
-
curLineObj.indent === lines[curLine].indent + 2 &&
|
|
21
|
-
optionsArr.push(curLine + indexShift);
|
|
19
|
+
curLineObj.line.startsWith("% option") && curLineObj.indent === lines[curLine].indent + 2 && optionsArr.push(curLine + indexShift);
|
|
22
20
|
indexShift++;
|
|
23
21
|
curLineObj = lines[curLine + indexShift];
|
|
24
22
|
}
|