Skip to content

Commit aba803a

Browse files
authored
refactor(yaml): add getIndentStatus function (#6903)
initial commit
1 parent 488ef44 commit aba803a

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

yaml/_loader_state.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ function markToString(
181181
return where;
182182
}
183183

184+
function getIndentStatus(lineIndent: number, parentIndent: number) {
185+
if (lineIndent > parentIndent) return 1;
186+
if (lineIndent < parentIndent) return -1;
187+
return 0;
188+
}
189+
184190
export class LoaderState {
185191
input: string;
186192
length: number;
@@ -1478,14 +1484,7 @@ export class LoaderState {
14781484
if (allowToSeek) {
14791485
if (this.skipSeparationSpace(true, -1)) {
14801486
atNewLine = true;
1481-
1482-
if (this.lineIndent > parentIndent) {
1483-
indentStatus = 1;
1484-
} else if (this.lineIndent === parentIndent) {
1485-
indentStatus = 0;
1486-
} else if (this.lineIndent < parentIndent) {
1487-
indentStatus = -1;
1488-
}
1487+
indentStatus = getIndentStatus(this.lineIndent, parentIndent);
14891488
}
14901489
}
14911490

@@ -1494,14 +1493,7 @@ export class LoaderState {
14941493
if (this.skipSeparationSpace(true, -1)) {
14951494
atNewLine = true;
14961495
allowBlockCollections = allowBlockStyles;
1497-
1498-
if (this.lineIndent > parentIndent) {
1499-
indentStatus = 1;
1500-
} else if (this.lineIndent === parentIndent) {
1501-
indentStatus = 0;
1502-
} else if (this.lineIndent < parentIndent) {
1503-
indentStatus = -1;
1504-
}
1496+
indentStatus = getIndentStatus(this.lineIndent, parentIndent);
15051497
} else {
15061498
allowBlockCollections = false;
15071499
}

0 commit comments

Comments
 (0)