Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

support for multiline suggestions #1452

Closed
oprogramador opened this issue Jan 8, 2019 · 41 comments
Closed

support for multiline suggestions #1452

oprogramador opened this issue Jan 8, 2019 · 41 comments

Comments

@oprogramador
Copy link

screen shot 2019-01-08 at 19 14 33

PR suggestions are a great feature because:

  • it saves time when resolving code review comments
  • as resolving comments is so simple, code reviewers don't have fear about reporting too many comments which resolving could slow down the development so we obtain a better code
  • it makes a clear git history because resolving each suggestion has its own commit

So it would be great to have also a possibility of multi-line suggestions (at least up to 5 lines) because sometimes a simple piece of code is split into several lines.

@oprogramador oprogramador changed the title support for mutliline suggestions support for multiline suggestions Jan 8, 2019
@Qix-
Copy link

Qix- commented May 22, 2019

Possible UX: click on line number to highlight, shift-click on another line to create range (identical to regular file views) and an add comment button appears with the suggestion already populated in a comment when clicked.

EDIT: Hey thanks for listening Github! :)

@w01fgang
Copy link

w01fgang commented May 25, 2019

GitLab supports multiline suggestions.
This will replace 2 lines above and 11 lines below the line.
Снимок экрана 2019-05-25 в 10 08 00

But the UX is not very good, to see the selected range you need to go to the preview tab. It would be great to highlight the selected range.

@FabioPinheiro
Copy link

FabioPinheiro commented May 29, 2019

@w01fgang can you point to a PR that have a multiline suggestion?
I would be grateful. I can not make it work.

Didn't show the GitLab part. I will try there

@ehsankhfr
Copy link

What's the status of development/review for this issue?

@Qix-
Copy link

Qix- commented Jul 10, 2019

@ehsankhfr This isn't an official tracker, and Github doesn't generally publicize their progress on anything nor do they confirm or deny even checking this tracker. However, history has shown a lot of the things suggested here make their way to mainline GH (see https://github.com/dear-github/dear-github which they did respond to).

I'm sure this will happen. But don't count on status updates.

And please stop asking the "status of things". This is OSS, things are done when they're done. Most OSS is done on our free time. If it gets implemented it'll be supported here. There's no secret society where we track stuff outside of github for our own amusement.

@glyn
Copy link

glyn commented Jul 10, 2019

And please stop asking the "status of things". This is OSS, things are done when they're done. Most OSS is done on our free time. If it gets implemented it'll be supported here. There's no secret society where we track stuff outside of github for our own amusement.

IMO it's reasonable to ask about status of an issue in OSS when you thinking about working on it and want to avoid duplicating someone else's work. @ehsankhfr: I don't suppose you were stepping forward to implement this were you? ;-)

@Qix-
Copy link

Qix- commented Jul 10, 2019

@glyn This isn't something that anyone from the public could implement, so that point is moot.

@glyn
Copy link

glyn commented Jul 10, 2019

Oops. Sorry.

@oprogramador
Copy link
Author

oprogramador commented Aug 9, 2019

Response from GitHub:

Thanks for writing in to GitHub Support!

We really appreciate feedback on how we can make GitHub even better and the best way to report any feature requests is directly to us through our community channels: https://github.community/

Please note that GitHub doesn't have an open feature request tracker and while https://github.com/isaacs/github/issues is a community resource, and as you have mentioned it's not officially supported by GitHub.

I'll go ahead and add your +1 for this feature to our internal list :)

I can’t make any promises as to if or when we may implement any changes, but I have shared your suggestion with the team for review and consideration.

Our roadmap is not publicly visible, so we recommend that you keep an eye on the GitHub Blog for the latest announcements about new features.

If you have any other questions, please do let us know.

So maybe each of us should send them an email in order to increase the probability of delivering this feature.

@Qix-
Copy link

Qix- commented Aug 9, 2019

That's a mostly canned response. I don't think GitHub really does anything with feature requests.

@jim-mason-dmxio
Copy link

hopefully this will be implemented soon

@fisher6
Copy link

fisher6 commented Aug 21, 2019

GitLab supports multiline suggestions.
This will replace 2 lines above and 11 lines below the line.
Снимок экрана 2019-05-25 в 10 08 00

But the UX is not very good, to see the selected range you need to go to the preview tab. It would be great to highlight the selected range.

I hope GitHub will soon implement this feature! I tend to give multiline refactor suggestion that just looks bad when the suggestion of code to refactor has only one line of code.
Thanks GitHub devs!

@chrisnevers
Copy link

Please implement this feature, GitHub!

@phanib
Copy link

phanib commented Sep 5, 2019

Much needed feature.

@chang
Copy link

chang commented Sep 6, 2019

GitHub has a short survey out where you can submit feedback on suggested changes: https://www.research.net/r/SuggestedChanges - this is probably the best way to be heard.
(from https://github.blog/2018-11-01-suggested-changes-update/)

@Qix-
Copy link

Qix- commented Oct 2, 2019

Multi-line comments are here, but the diffing still only supports the last line. Pretty shocking this is being missed lol. Feels like it'd be a natural feature to add...

@beatngu13
Copy link

@Qix- I wouldn't describe this as "shocking", multi-line comments are already a great improvement I think.

However, according to Nat Friedman (GitHub's CEO), multi-line suggestions are "[c]oming early next year".

@Qix-
Copy link

Qix- commented Oct 2, 2019

Thanks for the link @beatngu13, glad to see it's on their radar.

@Qix-
Copy link

Qix- commented Oct 7, 2019

@hernimen This is neither an official Github tracker nor is there a way for us to track the internal issues repository that Github uses. The only updates available in this issue tracker are those that are announced by Github.

What you see here is the most updated information the public is aware of.

@ferdnyc
Copy link

ferdnyc commented Oct 14, 2019

@Qix- I wouldn't describe this as "shocking", multi-line comments are already a great improvement I think.

It's pretty shocking, IMO they could've waited on debuting multi-line comments until they got suggestions working with them. As things stand right now we have this weird situation where you can either use multi-line comments, or suggestions — but not really together.

(Actually, suggestions have been pretty broken since the start, for always being limited to single-line changes. It's kind of pointless that they even offer a button that commits suggestions, when so many of them can't be committed as-is without breaking the code. That they brought out multi-line comments without first fixing THAT... I also find pretty shocking. You don't, I guess, and that's fine too.)

However, according to Nat Friedman (GitHub's CEO), multi-line suggestions are "[c]oming early next year".

Good news, I suppose.

@jdatskuid
Copy link

jdatskuid commented Oct 14, 2019

@ferdnyc Code suggestions are usually not tested and "from the hip". It's not the right place for significant changes. Code suggestions are for very minor changes, such as fixing a typo in a string or adjusting whitespace. Something that doesn't significantly alter the logic and doesn't require a fresh round of testing. Significant changes should be described by the reviewer in general terms and then implemented by the submitter, otherwise you might as well just add your own commit to the branch (which I have done before).

Multiline suggestions will be great and I'm looking forward to them but it's totally reasonable that, in a PR review, you would want to keep those suggestions small and limited.

@jdatskuid
Copy link

jdatskuid commented Oct 14, 2019

To be clear, I understand there is significant value in multi-line code suggestions. Indenting a whole block of code is great. Rewording an entire comment block, or fixing the order of JSDoc arguments, is mighty useful.

I was mostly responding to:

It's kind of pointless that they even offer a button that commits suggestions, when so many of them can't be committed as-is without breaking the code.

(emphasis mine)

If you have code suggestions that could break the logic, then maybe you aren't using code suggestions properly. It's not wise to make logic-changing suggestions in a PR and just hope and pray that your CI tools are good enough to pick up subtle changes that weren't intended. Heaven knows I've done this enough times in my own branch and the subtle change was too minor or edge-casey for the tests I had written. (Does that mean that my tests weren't sufficient? Yes, absolutely. Are yours? Are your colleagues'?)

If a PR requires significant changes, such that partially applied suggestions would be incompatible, then you should probably be making those changes in the branch and running the code and tests locally to make sure you aren't accidentally introducing breaking behavior.

Even if your CI tools are perfect, do you really want to start adding a flurry of commits via code suggestions to fix bone-headed and obvious bugs? You're just asking for an ugly and fractured git history. If you need to change the logic, then make the changes locally and push a commit when your tests pass.

@Qix-
Copy link

Qix- commented Oct 14, 2019

@jdatskuid The alternative is to create a branch off of a branch and PR into another pending PR. Quite the overhead for a two line change suggestion.

Also, It's not Github's place to tell me how to carry out my development tasks. They have a good history of providing tools that developers can use without getting philosophical about what they should use. Github stays out of my way unless I need them, and I attribute that to their continued success.

@navarr
Copy link

navarr commented Jan 17, 2020

It would appear that you can make suggestions off multiline comments manually, but they cannot be automatically applied at current.

You select the lines like making a multi-line comment, and then type the suggestion format:

```suggestion
code

and it works as expected. Preview does not show it, but posting it does.

@realFlowControl
Copy link

@navarr is right, just tried it out. In my case it even showed correct in the preview. All you have to do is to manually add the suggestion block

@ferdnyc
Copy link

ferdnyc commented Jan 27, 2020

@flow-control

Yes, that absolutely does work, but those comments are exactly the ones I was referring to when I said they "can't be committed as-is without breaking the code".

Fortunately, the "Commit Suggestion" button isn't active (any longer?) for suggestions in multi-line comments, so there's no danger of that happening.

But part of the value of structured suggestions — as opposed to simply leaving a comment saying:

Why don't we do this, instead?
```language
// Suggested alternative
// More code
```

...is the machinery that allows them to be quickly incorporated into the PR. That's something that's currently lost with "forced" multi-line suggestions, so there's effectively very little difference from the "manual" version above.

@JeHuiPark
Copy link

JeHuiPark commented Feb 22, 2020

@navarr is right, just tried it out. In my case it even showed correct in the preview. All you have to do is to manually add the suggestion block

Thanks!!
However, the proposal cannot be automatically accepted.

image

@beatngu13
Copy link

Tweet from Nat Friedman:

Shipping today on GitHub: multi-line suggestions!

@scottrigby
Copy link

@Qix-
Copy link

Qix- commented Feb 27, 2020

@clarkbw this can be closed. :)

@oprogramador
Copy link
Author

@Qix-

I forgot so I close it now.
Thanks for reminding.

@oprogramador
Copy link
Author

@isaacs @cirosantilli

could you add the implemented label?
I don't have such permissions

@trygveaa
Copy link

trygveaa commented Mar 1, 2020

I tried this, but it seems like adding suggestions when one of the lines is deleted is not supported?

When you have a suggestion for multiple lines, those lines will very often include deleted lines, since all changed lines show up as a pair of deleted and added, so this severely limits the usefulness of multiline suggestions.

@benmoss
Copy link

benmoss commented Apr 6, 2020

Anyone else who is going as insane as I just was: you have to select the lines going from top to bottom, and you have to click the "+" button next to the bottom-most line of your selection 🤦‍♂

@trygveaa
Copy link

trygveaa commented Apr 6, 2020

Yeah, not the most intuitive. If you drag on the plus instead of the line numbers, you don't have to click after dragging though.

@vittorioromeo
Copy link

I just ran into an issue on a Markdown project. I attempted to create a multiline-suggestion around some text which contained a code block:


Example blah blah

```cpp
foo bar
```

This is not automatically detected, and requires me to manually change the triple backtick to a sextuple backtick to avoid a collision.

@Qix-
Copy link

Qix- commented Apr 8, 2020

@SuperV1234 Send a message via the contact form at the bottom of any GitHub page - GitHub doesn't actually check this issue tracker (not officially, anyway).

@mastef
Copy link

mastef commented Sep 2, 2020

@SuperV1234 how did that work for you? I can't seem to be able to add a suggestion with a codeblock in it. It removes the ending triple backticks.

Works by using more than 3 backticks for the suggestion block
image

@GMNGeoffrey
Copy link

It would be nice if the generated suggestion block from GitHub did what mastef discovered above. Right now it will create invalid suggestion blocks when you click the button for any region containing codeblocks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests