Although I've not managed to use this spotting exploit through buildings, it definitely does work through things like corrugated iron fences, which is just absurd! I've already had a look for the BIS display that shows this information, but I can't find it in the configs (I looked in "/ca/ui/config.bin" and "/bin/config.bin", but it could be hidden somewhere else). If it could be found, then I imagine a simple addon could disable this x-ray vision, foe-recognition & magic range-finder exploit, once and for all!
The best I can come up with would be to disable the command button entirely, so that no-one could even bring up this command mode. This might just be acceptable in games when there weren't player-controlled AI, but really isn't a great solution. Haven't tried it, but it could be better than not being able to sort this out at all.
(this is almost certainly going to require an addon, rather than a scripted, fix, so should be moved to the appropriate forum).