Yes because in this case, the Rogue was never hidden. His Stealth check failed to beat the passive perception of his target.
The answer is
you dont have to. The rules allow a hidden creature to make an attack from hiding (leaning around the tree or pillar and making an unexpected attack)
all in one go. You don't reveal yourself until after the attack is resolved.
If it helps, think of the 'popping out' and shooting happening all at once.
Sage advice confirms here:
http://www.sageadvice.eu/2016/06/15...e-no-longer-hidden-is-that-2-conditions-or-1/
If you approach and atck you are no longer hidden. Is that 2 conditions or 1? A hiding bowman still gets adv?
@JeremyECrawford yes, bowman is hidden, melee attacker isn't unless he can keep hidden during approach
And here:
http://www.sageadvice.eu/2014/09/01/the-rogue-and-the-ogre/
Rogue Hides behind tree. Ogre can't see him. Leans out, shoots ogre, returns.
Advantage on attack? Sneak attack? Same next turn?
@mikemearls I would say
advantage on attack, disadvantage on check to hide again
If you stepped out from behind cover and started a conversation with your target before shooting him, you are no longer hidden. If you shoot him from your hiding spot, you are hidden right up until the attack is resolved (with advantage). Once resolved you are no longer hidden (hit or miss).
Just like you can keep an eye on someone from behind a pillar, or around a corner of an intersection or behind a tree, peeking out and remaining hidden.
I don't know how much clearer I can make it for you.