your-tools / ruplacer

Find and replace text in source files
BSD 3-Clause "New" or "Revised" License
443 stars 25 forks source link

Rewrite core functionality without using the difference crate #66

Closed dmerejkowsky closed 3 years ago

dmerejkowsky commented 3 years ago

Instead of just using string.replace or re.replace_all, actually do the work ourselves and compute a list of input and output fragments

Each fragment is a struct containing some text (either added or removed) and some position

This allows use to display the exact diff.

Implementation notes:

Old:

Patching foo/bar.js --- old is old +++ new is new

New:

foo/bar.js 3: old is old foo/bar.js 3: new is new

Fix #15

dmerejkowsky commented 3 years ago

I'm really proud of the new architecture. @tux3, would you mind taking a look and tell me what you think?

dmerejkowsky commented 3 years ago

Also, not really sure about the last commit ...

tux3 commented 3 years ago

Also, not really sure about the last commit ...

I like it, but I'm maybe a little biased, if you listened to me you would have lifetimes everywhere =)

cgestes commented 3 years ago

Sorry didnt have much time to review. But I very much like the idea. Next step is to make a proper release and post on r/commandline and/or r/rust ? 😆

dmerejkowsky commented 3 years ago

Yeah - probably ;)

cgestes commented 3 years ago

Cool, I tried locally it works better than before :) Did my best to review, but haven't been written rust in a while.

dmerejkowsky commented 3 years ago

@cgestes I think I addressed all your feedbacks in 3e6a052

If that's ok with you, we can merge this :)