Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Diff-like output #13

Closed
killercup opened this issue Jul 11, 2016 · 2 comments
Closed

Diff-like output #13

killercup opened this issue Jul 11, 2016 · 2 comments
Labels
enhancement help wanted postponed Later is better than never, right?

Comments

@killercup
Copy link
Member

While it's nice to read something like

Suggestion - Replace:

    mem::transmute::<*mut c_void,
                     &mut Box<FnMut(&MenuItem, &Window)>>(data)(&menu_item, &window);

with:

    &mut *(data as *mut Box<for<'r, 'r> std::ops::FnMut(&'r menus::MenuItem, &'r windows::Window)>)

it might be more useful to have a bit of context and see exactly what is getting replaced. A diff-view (with character-precision highlighting, not just lines) should work nicely.

This could also be an optional CLI flag, though it might be better to just keep rustfix as simple (and non-configurable) as possible for now.

This might be as easy as adjusting the "apply replacement" function to not always save the output and run print_diff over a slice of max(0, start.line - context)...min(file.lines().count(), end.line + context.

@mcarton
Copy link
Member

mcarton commented Jul 11, 2016

This could also be an optional CLI flag

IMO it should be the default.
By default show ±2 lines of context and change the prompt to:

What do you want to do? [r]eplace | show more [c]ontext | [s]kip | save and [q]uit | [a]bort (without saving)

Pressing c would add 2 more lines of context (or maybe the whole block?) and could be pressed as much as the user wants.

@killercup
Copy link
Member Author

Sounds good. How easy is it to find a block in rust code? Just going up/down to the first line that is indented one indent-level less might be viable.

@killercup killercup added the postponed Later is better than never, right? label May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement help wanted postponed Later is better than never, right?
Projects
None yet
Development

No branches or pull requests

2 participants