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

Condense output in presence of multiple suggestions #43

Merged
merged 4 commits into from
Nov 10, 2017
Merged

Conversation

oli-obk
Copy link
Collaborator

@oli-obk oli-obk commented Nov 7, 2017

part of #41

@@ -38,11 +36,11 @@ try
 --> src/controls.rs:373:5-378:6

try this
[0]: Suggestion - Replace:
[0]: At:
⍉pub fn new() -> Entry {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun bug, but this is a clippy bug, so I won't fix it here. Clippy should be placing this suggestion properly.

Copy link
Member

@killercup killercup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you! I left a few questions and suggestions for making the code a bit clearer.

src/main.rs Outdated
// check whether we can squash all suggestions into a list
if solution.replacements.len() > 1 {
let first = solution.replacements[0].clone();
if solution.replacements.iter().all(|s| first.snippet.file_name == s.snippet.file_name && first.snippet.line_range == s.snippet.line_range) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this in a let all_suggestion_are_alternatives_to_each_other = … (or something shorter)? Then, this line becomes the much more readable if all_suggestion_are_alternatives_to_each_other {.

src/main.rs Outdated
let first = solution.replacements[0].clone();
if solution.replacements.iter().all(|s| first.snippet.file_name == s.snippet.file_name && first.snippet.line_range == s.snippet.line_range) {
prelude(&first);
for suggestion in solution.replacements.iter() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't clippy suggest &solution.replacements here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think clippy throws up all kinds of things when used on rustfix. I never used it ;) I should. And I should feel bad for not having it done yet. ... Ah now I remember I wanted to fix rustfix with rustfix, but some clippy suggestions were breaking it. So I wanted to fix those first. I'm probably trapped in a loop

src/main.rs Outdated
println!(
"{lead}{text}{tail}",
lead = indent(4, &snippet.text.0),
text = "⍉".red(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with the apl functional symbol circle backslash here? Do you mean to convey that the text is empty here? Then: Did you mean to use the empty set—or actually ε?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted a pretty symbol. I would have preferred something like the google maps "you are here" marker. You know. with the pointy bottom and the round top.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like, ▲ or ▼?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idc. If you have sth you like, I'll use it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably best to use something people actually have in their terminal font… so, v or ^? I don't mind either way

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to change it, go ahead, otherwise i'm fine with merging with backslashed circle.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change it when I get back to a PC. Github web editing on mobile is a pain and would produce many commits ;)

src/main.rs Outdated
fn prelude(suggestion: &Replacement) {
let snippet = &suggestion.snippet;
if snippet.text.1.is_empty() {
if suggestion.replacement.ends_with('\n') || suggestion.replacement.starts_with('\n') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you testing here? What meaning does a replacement starting or ending with a newline have? Can you maybe rewrite this as let meaningful_name_of_usecase_here = …; if meaningful_name_of_usecase_here {?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

öhm... the use case is suggestions which wanna be on their own line... by being inserted after or before another line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh! Okay, that is pretty obvious…

-ly to be named let wants_to_be_on_own_line :D

println!("{}", "At:".yellow().bold());
println!(
"{lead}{text}{tail}",
lead = indent(4, &snippet.text.0),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memo for later refactoring: Turn text from (String, String, String) into struct ReplacementText { leading: String, content: String, trailing: String, }

@killercup
Copy link
Member

Thanks!

bors r+

bors bot added a commit that referenced this pull request Nov 10, 2017
43: Condense output in presence of multiple suggestions r=killercup a=oli-obk

part of #41
@bors
Copy link

bors bot commented Nov 10, 2017

Build succeeded

@bors bors bot merged commit a601912 into master Nov 10, 2017
@oli-obk oli-obk deleted the insert_message branch November 10, 2017 08:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants