@Nebucatnetzer - That’s fair.
Out of the box in preview, Obsidian applies autoscroll. That is, when the content is too long for the view pane, a scrollbar appears and it scrolls, keeping to the border of the code block (not outside, as in OP’s shot).
In editor, the long lines wrap so the content remains visible.
That’s a long way of saying (guessing) that the OP is probably using a theme that overrides default in some way. If it’s still an issue, he could let us know what theme he’s using, or contact the author to troubleshoot. If it’s a completely self-authored theme, then providing the code here could help, too.
@luckman212 - are you still having issues? If no, please let us know what worked. If yes, could you provide more details, please? Others may benefit from the answers we find, especially if they are using the same theme you are.