aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/language
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-09-04 22:07:32 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-09-06 01:05:24 +0200
commit7d8fe163fd4289787c9cb690db57a07b6b09095d (patch)
treeb100009a3af51eda3407f8b87f1b991a2bcab444 /subprojects/frontend/src/language
parentrefactor(frontend): Inter font (diff)
downloadrefinery-7d8fe163fd4289787c9cb690db57a07b6b09095d.tar.gz
refinery-7d8fe163fd4289787c9cb690db57a07b6b09095d.tar.zst
refinery-7d8fe163fd4289787c9cb690db57a07b6b09095d.zip
refactor(frontend): more readable indentation
Diffstat (limited to 'subprojects/frontend/src/language')
-rw-r--r--subprojects/frontend/src/language/indentation.ts13
1 files changed, 5 insertions, 8 deletions
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
79export function indentPredicateOrRule(context: TreeIndentContext): number { 79export 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}