Git is the one treating code like a text file instead of code.
Git store whole files. The diff and the merge algorithm works by line by default, but that's because line is a rough unit of code (statement, expression, and definition happens mostly within one line).
I pull out difftastic when it’s all too hard for this. Diffs based off tree sitter