cooolbros / vscode-vdf

VDF/Valve KeyValues language support for VSCode
https://marketplace.visualstudio.com/items?itemName=pfwobcke.vscode-vdf
GNU General Public License v3.0
22 stars 4 forks source link

Warn for duplicate values #28

Open rbjaxter opened 1 month ago

rbjaxter commented 1 month ago

It may not be a bad idea to warn when a panel has duplicate values (xpos, ypos, zpos, etc) that could be conflicting with each other. 99% of the time it's easy to catch when it happens, but it may not hurt to consider

cooolbros commented 1 month ago

This can definitely be added

Here are some things to consider:

Some keys are permitted to have duplicate keys (Such as resource/ui/hudmatchstatus.res RoundSignModel > model > animation), so to avoid false positives, only keys that are known to be unique should warn

If keys were to default to being unique, then some unknown valid VDF with multiple keys would warn, and if someone installs the extension only to get an incorrect warning that they can't remove, they will immediately uninstall, so we should under-warn instead of over-warn and only warn when we know we are correct.

Keys are case insensitive, so zpos and ZPOS are duplicates

Keys also have conditionals, so zpos 0 [$WIN32] and zpos 1 [$X360] are not duplicates

cooolbros commented 4 weeks ago

In Popfiles, a TFBot with an attribute subkey such as Health before a Template reference subkey that also contains the same attribute (Health) will cause a conflict and TF2 will load the subkey from the Template. To override the TFBot Health, the Health key must appear after the Template reference.

I haven't checked to see if this behaviour is different in entry files and #base files. The HUD Merger has a data loader for HUD layout files which can be used as a reference, hopefully the behaviour is similar