Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 15 additions & 28 deletions src/components/Languages/Mcfunction/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,24 +523,8 @@ export class CommandData extends Signal<void> {
): Promise<ICompletionItem[]> {
const { languages } = await useMonaco()

// Test whether argument type is defined
if (!commandArgument.type) {
// If additionalData is defined, return its values
if (commandArgument.additionalData?.values)
return this.toCompletionItem(
commandArgument.additionalData?.values
)
else if (commandArgument.additionalData?.schemaReference)
return this.toCompletionItem(
<string[]>(
this.resolveDynamicReference(
commandArgument.additionalData.schemaReference
).map(({ value }) => value)
)
)

return []
}
// If argument type isn't defined, set it to "string" to use "additonalData" property
commandArgument.type ??= 'string'

switch (commandArgument.type) {
case 'command':
Expand Down Expand Up @@ -573,23 +557,26 @@ export class CommandData extends Signal<void> {
languages.CompletionItemKind.Operator
)
case 'string': {
let values: string[] = []
if (commandArgument.additionalData?.values)
return this.toCompletionItem(
commandArgument.additionalData.values,
commandArgument.description,
languages.CompletionItemKind.Constant
values = values.concat(
commandArgument.additionalData.values
)
else if (commandArgument.additionalData?.schemaReference)
return this.toCompletionItem(
if (commandArgument.additionalData?.schemaReference)
values = values.concat(
<string[]>(
this.resolveDynamicReference(
commandArgument.additionalData.schemaReference
).map(({ value }) => value)
),
commandArgument.description,
languages.CompletionItemKind.Constant
)
)
else return []

if (values.length === 0) return []
return this.toCompletionItem(
values,
commandArgument.description,
languages.CompletionItemKind.Constant
)
}
case 'jsonData':
return this.toCompletionItem(
Expand Down