xfbs / diff.rs

Web application to render a diff between Rust crate versions. Implemented in Yew, runs fully in the browser as WebAssembly.
https://diff.rs
MIT License
105 stars 11 forks source link

WIP default context folding #12

Closed Alphare closed 1 year ago

Alphare commented 1 year ago

This is a draft, I have a working state after a long session and I haven't had time to really polish, clean up the code or make real commits. I wanted to give you a change to give your feedback for the general feel of it.

Should address most of what #7 asked for. It's still not as good as I'd like it to be: we should be able to show fewer lines of context than the entire folded group, as well as provide the most relevant folded line (generally function or struct etc., which requires some language-level semantics, or just plain indentation lookup).

It's way too late to be up, sorry for rambling, I'll get some sleep.

xfbs commented 1 year ago

Awesome work on this, thanks a lot!

I got it working locally, looks really good so far. I'm adding some comments here and there with some ideas.

As for the context, I think indentation lookup should work, no? That sounds like it'd be the easiest to implement.

xfbs commented 1 year ago

If you get a chance, you can check out https://github.com/xfbs/diff.rs/tree/small-context, I've rebased your branch and unified the changes and the context_ranges into a FileDiff type.

Alphare commented 1 year ago

Thanks, hopefully I'll get a chance to work on it before tomorrow. :)

Alphare commented 1 year ago

I've fought a very nasty use_state-related bug that turned out to be due to the lack of key in the diff list. A (late) evening well spent, heh.

I've also fixed a couple of bugs, I'm hoping to get this to an upstream-able state tomorrow, no promises though.

Alphare commented 1 year ago

I lied, I cleaned up the PR because it wasn't that much work. I think this can be merged in this state, with improvements to both usability and style (because it's ugly) coming later (as said in the commits), what do you think?

xfbs commented 1 year ago

I think this looks really good. I saw that previously it would not show button to expand on files where there weren't any changes, but that's now fixed. I think we're good to merge this one. Awesome work!