eavesdropping

Hearing someone's conversation

Q: My question is, what happens when you hear someone's conversation while having bad thoughts but then you realise during the conversation that you were not supposed to hear it and immediately divert your attention? Do you get the sin even though you diverted your attention right away or do not get it due to you not remembering that specific commandment of Allah Ta'ala?