[Feature Request] Add code suggestion for PR review comments #6908

Open
opened 2025-11-02 07:10:47 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @delvh on GitHub (Feb 21, 2021).

  • Gitea version (or commit ref): 1.14.0+dev-740-g7118347ba

Description

GitHub supports the option to add code suggestions that can automatically overwrite the current code if committed. The user has the option to add infinitely many suggestions together in a batch before committing all in one single code review commit.
Any code review comment can contain suggestions by simply using

```suggestion
``` (no text here, solely exists so that the quotes at the beginning will be displayed correctly)

The text that gets replaced is the text selected for this comment, resulting in this issue being effectively blocked until #12640 gets merged.
Of course, it would already be possible to implement, but limited to single-line code suggestions for now.

Later on, this feature could even be enhanced to use additional language highlighting, so that the recommendations would even be displayed in the style of the given language. This could look something like this then:

```<language> suggestion

, for example

```go suggestion

This is a useful feature as it allows integrating code suggestions way quicker and without the help of any external tool, where each change has to be manually located first.

Screenshots

Current design on GitHub:
image

behavior when there are multiple suggestions in one comment:
image

Originally created by @delvh on GitHub (Feb 21, 2021). - Gitea version (or commit ref): 1.14.0+dev-740-g7118347ba ## Description GitHub supports the option to add code suggestions that can automatically overwrite the current code if committed. The user has the option to add infinitely many suggestions together in a batch before committing all in one single code review commit. Any code review comment can contain suggestions by simply using ``` ```suggestion ``` (no text here, solely exists so that the quotes at the beginning will be displayed correctly) ``` The text that gets replaced is the text selected for this comment, resulting in this issue being effectively blocked until #12640 gets merged. Of course, it would already be possible to implement, but limited to single-line code suggestions for now. Later on, this feature could even be enhanced to use additional language highlighting, so that the recommendations would even be displayed in the style of the given language. This could look something like this then: ``` ```<language> suggestion ``` , for example ``` ```go suggestion ``` This is a useful feature as it allows integrating code suggestions way quicker and without the help of any external tool, where each change has to be manually located first. ## Screenshots Current design on GitHub: ![image](https://user-images.githubusercontent.com/51889757/108627005-8a84d200-7453-11eb-9dc9-a7f76be2a5ff.png) behavior when there are multiple suggestions in one comment: ![image](https://user-images.githubusercontent.com/51889757/108627320-4266af00-7455-11eb-9b47-690069e4b4c5.png)
GiteaMirror added the topic/prtype/featuretype/proposalproposal/accepted labels 2025-11-02 07:10:47 -06:00
Author
Owner

@a1012112796 commented on GitHub (Feb 22, 2021):

I think this issue is duplicate of https://github.com/go-gitea/gitea/issues/9388.

@a1012112796 commented on GitHub (Feb 22, 2021): I think this issue is duplicate of https://github.com/go-gitea/gitea/issues/9388.
Author
Owner

@delvh commented on GitHub (Feb 22, 2021):

Well, partially. As @6543 pointed out in the issue description, it could be applied to this issue.
Problem one not covered in that issue: From the issue title, it can't be assumed that code suggestions (as they are called on GitHub) are meant (hence that issue can't be found when someone wants code suggestions to be implemented).
Problem two: That issue currently provides no screenshot of how an existing implementation looks like
Problem three: The issue does not point out that multiple diffs should be able to be combined into a single commit.
If all of that gets moved there, then this issue can be closed as duplicate

@delvh commented on GitHub (Feb 22, 2021): Well, partially. As @6543 pointed out in the issue description, it could be applied to this issue. Problem one not covered in that issue: From the issue title, it can't be assumed that code suggestions (as they are called on GitHub) are meant (hence that issue can't be found when someone wants code suggestions to be implemented). Problem two: That issue currently provides no screenshot of how an existing implementation looks like Problem three: The issue does not point out that multiple diffs should be able to be combined into a single commit. If all of that gets moved there, then this issue can be closed as duplicate
Author
Owner

@silverwind commented on GitHub (May 12, 2023):

As requested in https://github.com/go-gitea/gitea/issues/24681, it should also be possible to just comment on multiple lines via shift-click selection, even without an suggestion.

@silverwind commented on GitHub (May 12, 2023): As requested in https://github.com/go-gitea/gitea/issues/24681, it should also be possible to just comment on multiple lines via shift-click selection, even without an suggestion.
Author
Owner

@0dminnimda commented on GitHub (Sep 27, 2023):

What is the progress on this one?

@0dminnimda commented on GitHub (Sep 27, 2023): What is the progress on this one?
Author
Owner

@silverwind commented on GitHub (Nov 2, 2023):

```<language> suggestion

I see no need for this. Language can just be determined from the currently edited file for syntax highlighting purpose.

@silverwind commented on GitHub (Nov 2, 2023): > ` ```<language> suggestion` I see no need for this. Language can just be determined from the currently edited file for syntax highlighting purpose.
Author
Owner

@Glandos commented on GitHub (Nov 7, 2023):

```<language> suggestion

I see no need for this. Language can just be determined from the currently edited file for syntax highlighting purpose.

If the file is an HTML file, and the suggestion is within a <script> tag, then the highlight language is not HTML.

In Vue SFC, it's more complicated, the <script> tag can have a lang attribute, defining script as Javascript, Typescript, or else.

@Glandos commented on GitHub (Nov 7, 2023): > > `` ```<language> suggestion `` > > I see no need for this. Language can just be determined from the currently edited file for syntax highlighting purpose. If the file is an HTML file, and the suggestion is within a `<script>` tag, then the highlight language is not HTML. In Vue SFC, it's more complicated, the `<script>` tag can have a `lang` attribute, defining script as Javascript, Typescript, or else.
Author
Owner

@2bndy5 commented on GitHub (Dec 20, 2024):

```<language> suggestion

I see no need for this. Language can just be determined from the currently edited file for syntax highlighting purpose.

I would argue that syntax highlighting is not feasible. The resulting code block would be rendered with diff syntax.

- remove this
+ replace with this

Adding syntax highlighting for a different language (rendered within the diff syntax) is an unnecessary complexity and may be counterintuitive to those that are unfamiliar with code suggestion blocks.

@2bndy5 commented on GitHub (Dec 20, 2024): > > `` ```<language> suggestion `` > > I see no need for this. Language can just be determined from the currently edited file for syntax highlighting purpose. I would argue that syntax highlighting is not feasible. The resulting code block would be rendered with diff syntax. ```diff - remove this + replace with this ``` Adding syntax highlighting for a different language (rendered within the `diff` syntax) is an unnecessary complexity and may be counterintuitive to those that are unfamiliar with code `suggestion` blocks.
Author
Owner

@pascal-ws commented on GitHub (Jul 30, 2025):

Hey there, really waiting for this feature (+ multiline comments) as I am used to this in both GitLab and GitHub and it's a bummer this isn't already implemented.

Additionally (not sure if this would be a separate feature request but) in GitLab it's possible to commit all (selected) suggestions with one click and one commit (not one suggestion = one commit). This is just a minor improvement but can help in certain scenarios. Would be nice, if this was possible in Gitea, too.

@pascal-ws commented on GitHub (Jul 30, 2025): Hey there, really waiting for this feature (+ multiline comments) as I am used to this in both GitLab and GitHub and it's a bummer this isn't already implemented. Additionally (not sure if this would be a separate feature request but) in GitLab it's possible to commit all (selected) suggestions with one click and one commit (not one suggestion = one commit). This is just a minor improvement but can help in certain scenarios. Would be nice, if this was possible in Gitea, too.
Author
Owner

@0dminnimda commented on GitHub (Jul 30, 2025):

A good question is what are the approximate steps to implement this, so if anyone needs it badly, they can do it themselves.

@0dminnimda commented on GitHub (Jul 30, 2025): A good question is what are the approximate steps to implement this, so if anyone needs it badly, they can do it themselves.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6908