From 7d8fe163fd4289787c9cb690db57a07b6b09095d Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sun, 4 Sep 2022 22:07:32 +0200 Subject: refactor(frontend): more readable indentation --- subprojects/frontend/src/index.tsx | 6 ++++-- subprojects/frontend/src/language/indentation.ts | 13 +++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'subprojects') diff --git a/subprojects/frontend/src/index.tsx b/subprojects/frontend/src/index.tsx index 9f413b85..602a68ef 100644 --- a/subprojects/frontend/src/index.tsx +++ b/subprojects/frontend/src/index.tsx @@ -33,14 +33,16 @@ enum TaxStatus { pred invalidTaxStatus(Person p) <-> taxStatus(p, child), children(p, _q) - ; taxStatus(p, retired), +; + taxStatus(p, retired), parent(p, q), !taxStatus(q, retired). rule createChild(may Person p, must Person newPerson): may children(p, newPerson), may !equals(newPerson, newPerson) -==> new q <: newPerson, +==> + new q <: newPerson, children(p, q), taxStatus(q, child). diff --git a/subprojects/frontend/src/language/indentation.ts b/subprojects/frontend/src/language/indentation.ts index 0bd2423c..b49d6563 100644 --- a/subprojects/frontend/src/language/indentation.ts +++ b/subprojects/frontend/src/language/indentation.ts @@ -38,11 +38,11 @@ function findAlignmentAfterOpening(context: TreeIndentContext): number | null { * https://github.com/codemirror/language/blob/cd7f7e66fa51ddbce96cf9396b1b6127d0ca4c94/src/indent.ts#L275 * * @example - * Result with no hanging indent (indent unit = 2 spaces, units = 1): + * Result with no hanging indent (indent unit = 4 spaces, units = 1): * ``` * scope - * Family = 1, - * Person += 5..10. + * Family = 1, + * Person += 5..10. * ``` * * @example @@ -78,11 +78,8 @@ export function indentDeclaration(context: TreeIndentContext): number { export function indentPredicateOrRule(context: TreeIndentContext): number { const clauseIndent = indentDeclarationStrategy(context, 1); - if (/^\s+[;.]/.exec(context.textAfter) !== null) { - return clauseIndent - 2; - } - if (/^\s+(==>)/.exec(context.textAfter) !== null) { - return clauseIndent - 4; + if (/^\s+(?:==>|[;.])/.exec(context.textAfter) !== null) { + return clauseIndent - context.unit; } return clauseIndent; } -- cgit v1.2.3-70-g09d2