Where, on the trial on indictment of any person charged with the commissioning of an offence, medical evidence is given that the person charged was an insane person at the time the offence was committed, and the jury finds that although the person charged did the act or made the omission, he or she was an insane person at that time, the section provides that, in these circumstances, the court must direct a finding that the person is not guilty on the grounds of insanity.