That'll happen, yes, and when the enemy steps near you, you can do one of two things:
- Surprise attack them (because they didn't have vision on you between their last turn and your current turn).
- Take one step away from them, causing them to lose track of you for a moment, and then take a second step away from them and now they have completely lost track of you and will likely leave the room. (Not always.) They are usually smart enough to follow you after the first step, but after the second, they will flash a "?" above their head, and you've officially lost them. But they can still randomly walk next to you again.
You can do a sneak attack, then take 1 step, then do another sneak attack, forever. You will get guaranteed hits, but their attacks can still be evaded. But they might at some point lose track of you.
So, if you're going to wait in that room to heal or recover artifact charges or wand charges, do so close to the door so you have plenty of room to walk away from enemies.
If you have some sort of mind vision and ranged weapons, you can get surprise attacks them them without retaliatory attacks.