decompme / decomp.me

Collaborative decompilation and reverse engineering website
https://decomp.me
MIT License
348 stars 108 forks source link

Scroll to line when clicking line number #1236

Open 1superchip opened 1 month ago

1superchip commented 1 month ago

Scroll to line in source tab when line numbers in diff are clicked.

This does not highlight the newly selected line.

Related to https://github.com/decompme/decomp.me/issues/115. "Click a line number to jump to it in the source"

This should be reviewed.

ethteck commented 1 month ago

I forgot to write here, but I think we should adjust this to be more React friendly before merging. It's good to have this as a starting point, though. but stuff like getElementsByClassName isn't ideal for a react project like this

bates64 commented 1 month ago

Agreed with @ethteck. The way this PR is currently written requires that there only be one CodeMirror on the page at once, which is the case today, but might not be the case in future.

To do this in a more React-like way, a ref to the CodeMirror element should be provided via context, probably from the top-level Scratch editor component. Then when this button is clicked, you can do .getElementsByClassName on the ref instead of on the entire document.