ambuda
ambuda copied to clipboard
[proofing] Fully clean up search/replace UX
These changes build on @kvchitrapu's prior work and simplify it slightly.
Specifically, this makes the following changes:
- collapse the UX from 4 phases (search, check, confirm, submit) to 3 (search, check, submit) -- I felt that the "confirm" stage was not adding much as compared to the complexity it added.
- create a single
_find_replacements
utility function that does the regex searching, etc. By using dataclasses, we can reuse this one function for the full flow. - add unit tests to increase test coverage
Proposed flow:




@kvchitrapu I made some substantial changes here so that the UX cleanup could go a little smoothly. I think this preserves your original vision but I'm curious what you think of the new changes.
Edit -- I should also mention that I love the logging but that I found it very difficult to read the code with them. Would love to find a balance between logging and keeping the code readable.
Thanks for the review!
For instance, I do not simply run a "search-replace" all in an editor when renaming a variable. Instead, I go through each line to ensure precision.
I agree that a blind search/replace is unwise and that the user must review each change to ensure quality. My feeling is that the phase where the user checks/unchecks each item in the result set accomplishes this purpose already. I'm curious why you feel differently.
Sorry @akprasad . I intended to get back to my regular routine last week, but I couldn't find time to unblock my schedule. I'll get back on track this week.
@akprasad , go forward with this PR and land it. Consider adding an assert to catch lines that escape odd/even structure. Record user's regex
in the log message.