Acts 13:22 And when He had removed him, He raised up for them David as king, to whom also He gave testimony and said, ‘I have found David the son of Jesse, a man after My own heart, who will do all My will.’
God promised to put His law in our hearts. Our hearts can only do what these laws says if led by the Spirit. John 4:24 God is Spirit, and those who worship Him must worship in spirit and truth.”
Obedience or disobedience to the Spirit results in the character of the heart. The Bible further advise that a bad tree cannot bear bad fruits. Our hearts can only produce good results if led by the Spirit. What we see with our eyes, only reflects the state of a man’s heart. Matthew 15:18 But those things which proceed out of the mouth come from the heart, and they defile a man.
You can be led to repentance after committing sin but man can be stuck with what they saw.