diff --git a/packages/server/src/VDF/VDFLanguageServer.ts b/packages/server/src/VDF/VDFLanguageServer.ts index a1f939a..2a87dc6 100644 --- a/packages/server/src/VDF/VDFLanguageServer.ts +++ b/packages/server/src/VDF/VDFLanguageServer.ts @@ -111,7 +111,7 @@ export abstract class VDFLanguageServer< // @ts-ignore return [ ...(value.reference ? value.reference.flatMap(include) : []), - ...value.values.filter((value) => (text ? value.label.toLowerCase().startsWith(text.toLowerCase()) : true) && (value.multiple ? true : !documentSymbol.children?.some((d) => d.key.toLowerCase() == value.label.toLowerCase()))) + ...value.values?.filter((value) => (text ? value.label.toLowerCase().startsWith(text.toLowerCase()) : true) && (value.multiple ? true : !documentSymbol.children?.some((d) => d.key.toLowerCase() == value.label.toLowerCase()))) ?? [] ] } diff --git a/packages/server/src/VDF/VDFTextDocument.ts b/packages/server/src/VDF/VDFTextDocument.ts index c7bcdf0..db2044e 100644 --- a/packages/server/src/VDF/VDFTextDocument.ts +++ b/packages/server/src/VDF/VDFTextDocument.ts @@ -48,7 +48,7 @@ export interface VDFTextDocumentDependencies { } export interface VDFTextDocumentSchema { - keys: Record + keys: Record values: Record }> definitionReferences: { type: symbol @@ -386,6 +386,41 @@ export abstract class VDFTextDocument configuration.keyTransform(i.key.toLowerCase()) == documentSymbolKey && i.conditional?.toLowerCase() == documentSymbol.conditional?.toLowerCase())! + if (first != documentSymbol) { + diagnostics.push({ + range: documentSymbol.nameRange, + severity: DiagnosticSeverity.Warning, + code: "duplicate-key", + source: init.languageId, + message: `Duplicate ${first.key}`, + relatedInformation: [ + { + location: { + uri: this.uri.toString(), + range: first.nameRange + }, + message: `${first.key} is declared here.` + } + ], + data: { + kind: CodeActionKind.QuickFix, + fix: (createDocumentWorkspaceEdit) => { + return { + title: `Remove duplicate ${documentSymbol.key}`, + edit: createDocumentWorkspaceEdit(documentSymbol.range, "") + } + } + } + }) + } + } + } + // Static if (documentSymbolKey in dependencies.schema.values) { const valueData = dependencies.schema.values[documentSymbolKey] diff --git a/packages/server/src/VDF/VGUI/keys.json b/packages/server/src/VDF/VGUI/keys.json index 4aa1d6b..6e9a172 100644 --- a/packages/server/src/VDF/VGUI/keys.json +++ b/packages/server/src/VDF/VGUI/keys.json @@ -1,4 +1,7 @@ { + "autoresize": { + "distinct": true + }, "button": { "reference": [ "cexlabel" @@ -48,6 +51,9 @@ } ] }, + "controlname": { + "distinct": true + }, "ctfimagepanel": { "reference": [ "imagepanel" @@ -82,6 +88,12 @@ } ] }, + "enabled": { + "distinct": true + }, + "fieldname": { + "distinct": true + }, "imagepanel": { "reference": [ "panel" @@ -263,5 +275,26 @@ "kind": 5 } ] + }, + "pincorner": { + "distinct": true + }, + "tall": { + "distinct": true + }, + "visible": { + "distinct": true + }, + "wide": { + "distinct": true + }, + "xpos": { + "distinct": true + }, + "ypos": { + "distinct": true + }, + "zpos": { + "distinct": true } }