entities: (
[WeightedListEntry] |
#[id(registry="entity_type", tags="allowed")] string |
[#[id="entity_type"] string] |
),
results in
If I click either list entry I get the structure of the first list entry
Meaning I'm not able to define entries using just a list of strings
I tried appending the index here for duplicates
(Preferable there'd be an option to give the data type applied to the field a proper id or sth. like that)
|
<option value={index}>{formatUnionMember(member, type.members.filter(m => m !== member))}</option> |
But if I select the List 2 it just switches to List
To fix that issue I had to add this part
Just adjusting the equals method did not allow me to switch from List to List 2 directly
(Because an empty list would be equal in the check in getChange? So you need at least 1 entry to properly compare? Don't fully understand it)
Index: src/app/components/generator/McdocHelpers.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/app/components/generator/McdocHelpers.ts b/src/app/components/generator/McdocHelpers.ts
--- a/src/app/components/generator/McdocHelpers.ts (revision 52c51dd418e93a9b2aa5159ca47ede05e298bc75)
+++ b/src/app/components/generator/McdocHelpers.ts (date 1763541462269)
@@ -118,8 +118,9 @@
if (isListOrArray(type)) {
const array = JsonArrayNode.mock(range)
const minLength = type.lengthRange?.min ?? 0
- if (minLength > 0) {
- for (let i = 0; i < minLength; i += 1) {
+ const count = (type.lengthRange?.max === 0) ? 0 : Math.max(1, minLength)
+ if (count > 0) {
+ for (let i = 0; i < count; i += 1) {
const child = getDefault(simplifyType(getItemType(type), ctx), range, ctx)
const itemNode: core.ItemNode<JsonNode> = {
type: 'item',
@@ -488,6 +489,20 @@
const keyB = b.fields[0]?.key
return (!keyA && !keyB) || (keyA && keyB && quickEqualTypes(keyA, keyB))
}
- // Types are of the same kind
+
+ if (a.kind === 'list' && b.kind === 'list') {
+ return quickEqual(a.item, b.item)
+ }
+
+ // Types are of the same kind
return true
}
+
+function quickEqual(a: SimplifiedMcdocType, b: SimplifiedMcdocType): boolean {
+ if (a.kind === 'union' && b.kind === 'union') {
+ if (a.members.length !== b.members.length) return false
+ return a.members.every((m, i) => quickEqualTypes(m, b.members[i]))
+ }
+ if (a.kind === 'union' || b.kind === 'union') return false
+ return quickEqualTypes(a, b)
+}
results in
If I click either list entry I get the structure of the first list entry
Meaning I'm not able to define entries using just a list of strings
I tried appending the index here for duplicates
(Preferable there'd be an option to give the data type applied to the field a proper id or sth. like that)
misode.github.io/src/app/components/generator/McdocRenderer.tsx
Line 412 in e38ec67
But if I select the
List 2it just switches toListTo fix that issue I had to add this part
Just adjusting the equals method did not allow me to switch from
ListtoList 2directly(Because an empty list would be equal in the check in
getChange? So you need at least 1 entry to properly compare? Don't fully understand it)