diff options
author | 2022-09-04 22:07:32 +0200 | |
---|---|---|
committer | 2022-09-06 01:05:24 +0200 | |
commit | 7d8fe163fd4289787c9cb690db57a07b6b09095d (patch) | |
tree | b100009a3af51eda3407f8b87f1b991a2bcab444 /subprojects/frontend | |
parent | refactor(frontend): Inter font (diff) | |
download | refinery-7d8fe163fd4289787c9cb690db57a07b6b09095d.tar.gz refinery-7d8fe163fd4289787c9cb690db57a07b6b09095d.tar.zst refinery-7d8fe163fd4289787c9cb690db57a07b6b09095d.zip |
refactor(frontend): more readable indentation
Diffstat (limited to 'subprojects/frontend')
-rw-r--r-- | subprojects/frontend/src/index.tsx | 6 | ||||
-rw-r--r-- | subprojects/frontend/src/language/indentation.ts | 13 |
2 files changed, 9 insertions, 10 deletions
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 { | |||
33 | pred invalidTaxStatus(Person p) <-> | 33 | pred invalidTaxStatus(Person p) <-> |
34 | taxStatus(p, child), | 34 | taxStatus(p, child), |
35 | children(p, _q) | 35 | children(p, _q) |
36 | ; taxStatus(p, retired), | 36 | ; |
37 | taxStatus(p, retired), | ||
37 | parent(p, q), | 38 | parent(p, q), |
38 | !taxStatus(q, retired). | 39 | !taxStatus(q, retired). |
39 | 40 | ||
40 | rule createChild(may Person p, must Person newPerson): | 41 | rule createChild(may Person p, must Person newPerson): |
41 | may children(p, newPerson), | 42 | may children(p, newPerson), |
42 | may !equals(newPerson, newPerson) | 43 | may !equals(newPerson, newPerson) |
43 | ==> new q <: newPerson, | 44 | ==> |
45 | new q <: newPerson, | ||
44 | children(p, q), | 46 | children(p, q), |
45 | taxStatus(q, child). | 47 | taxStatus(q, child). |
46 | 48 | ||
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 { | |||
38 | * https://github.com/codemirror/language/blob/cd7f7e66fa51ddbce96cf9396b1b6127d0ca4c94/src/indent.ts#L275 | 38 | * https://github.com/codemirror/language/blob/cd7f7e66fa51ddbce96cf9396b1b6127d0ca4c94/src/indent.ts#L275 |
39 | * | 39 | * |
40 | * @example | 40 | * @example |
41 | * Result with no hanging indent (indent unit = 2 spaces, units = 1): | 41 | * Result with no hanging indent (indent unit = 4 spaces, units = 1): |
42 | * ``` | 42 | * ``` |
43 | * scope | 43 | * scope |
44 | * Family = 1, | 44 | * Family = 1, |
45 | * Person += 5..10. | 45 | * Person += 5..10. |
46 | * ``` | 46 | * ``` |
47 | * | 47 | * |
48 | * @example | 48 | * @example |
@@ -78,11 +78,8 @@ export function indentDeclaration(context: TreeIndentContext): number { | |||
78 | 78 | ||
79 | export function indentPredicateOrRule(context: TreeIndentContext): number { | 79 | export function indentPredicateOrRule(context: TreeIndentContext): number { |
80 | const clauseIndent = indentDeclarationStrategy(context, 1); | 80 | const clauseIndent = indentDeclarationStrategy(context, 1); |
81 | if (/^\s+[;.]/.exec(context.textAfter) !== null) { | 81 | if (/^\s+(?:==>|[;.])/.exec(context.textAfter) !== null) { |
82 | return clauseIndent - 2; | 82 | return clauseIndent - context.unit; |
83 | } | ||
84 | if (/^\s+(==>)/.exec(context.textAfter) !== null) { | ||
85 | return clauseIndent - 4; | ||
86 | } | 83 | } |
87 | return clauseIndent; | 84 | return clauseIndent; |
88 | } | 85 | } |