How can I manually add suggestions in code reviews on GitHub?

Viewed 3141

In GitHub it's possible to suggest code changes through inline comments in pull requests. But I always get the following error message: "suggestions cannot be applied while viewing a subset of changes".

Is there also a way to manually suggest changes in a comment?

Example: screenshot of problem

2 Answers

Besides the button you can also actually use syntax to make a suggestion. You can do it like:

```suggestion
this is my new suggestion
```

How-to code suggest to multiple lines

Apply a code suggestion to multiple lines by highlight dragging the code lines. Starting drag to the right of the line numbers where the comment plus icon appears.

Start dragging

Verify by seeing "Commenting on lines +129 to +145" (or similar) text indicating the multiple line range you are commenting on.

Verify step

Now the code suggestion will replace more than one line!

Related