I found this:
@VerysArkon : When does "hidden" end? As soon as a creatures moves into line-of-sight from behind cover or after the ranged attack is made?
@mike Mearls: As soon as the creature is fully visible or attacks - DM judgment on visibility (ex: sniper hiding behind a corner).
"Fully" visible or attacks seems to be a key statement (as does DM judgement).
Yeah, if you stay hidden and attack (like attacking from darkness) you are good but since the halfling revealed himself before taking the shot then it requires a DM ruling to get advantage.