Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Full-file syntax highlighting for diff pages#33766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
wxiaoguang merged 31 commits intogo-gitea:mainfromdfirebaugh:git-diff-highlights
Mar 9, 2025

Conversation

@dfirebaugh
Copy link
Contributor

@dfirebaughdfirebaugh commentedMar 2, 2025
edited by wxiaoguang
Loading

Fix#33358,fix#21970

This adds a step in theGitDiff that does syntax highlighting for the entire file and then only references lines from that syntax highlighted code. This allows things like multi-line comments to be syntax highlighted correctly.

image (4)
image (3)
image (2)
image (1)
image

silverwind and hiifong reacted with hooray emoji
@GiteaBotGiteaBot added the lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelMar 2, 2025
@github-actionsgithub-actionsbot added the modifies/goPull requests that update Go code labelMar 2, 2025
@wxiaoguangwxiaoguang marked this pull request as draftMarch 2, 2025 03:13
wxiaoguang
wxiaoguang previously requested changesMar 2, 2025
Copy link
Contributor

@wxiaoguangwxiaoguang left a comment
edited
Loading

Choose a reason for hiding this comment

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

HTML encoding should be correctly handled, for example:<>

See new comment below#33766 (comment)

@GiteaBotGiteaBot added lgtm/blockedA maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelsMar 2, 2025
@wxiaoguang

This comment was marked as outdated.

@pull-request-sizepull-request-sizebot added size/M and removed size/L labelsMar 2, 2025
@pull-request-sizepull-request-sizebot added size/L and removed size/M labelsMar 2, 2025
@wxiaoguang
Copy link
Contributor

wxiaoguang commentedMar 2, 2025
edited
Loading

Thank you very much. I can understand most of changes now. The idea is feasible, while there are still some details:

  1. Some of the old tests should be kept, for example:diff.Text = "OC", I do not see why it should be removed. It is used to make sure therecoverOneDiff works correctly.
  2. Some of the old tests do not fit the new code:
    • If a test doesn't fit (the case won't happen), feel free to remove it.
    • New tests should cover the new behavior since the behavior ofdiffWithHighlight has changed, it only accepts HTML content
  3. Some variable types should be changed to match the new behavior, usetemplate.HTML
  4. Some edge cases, for example, what if a file is large (Mega-bytes)? It would bloat the Gitea's memory and make it OOM.
    • I think we need to have a limit, if a file is too large, fall back to the "hunk block" diff but not the "full file" diff.

@silverwind
Copy link
Member

silverwind commentedMar 2, 2025
edited
Loading

I think we need to have a limit, if a file is too large, fall back to the "hunk block" diff but not the "full file" diff.

Sounds acceptable to have a certain byte limit above which to fall back to hunk-based diff. Maybe 1-5MB or so.

- adding conditions for when full file based highlighting should occur- falling back to hunk based highlighting in certain conditions- reverting original hunk-based highlighting tests- updating types to express intent better and to be more accurate i.e. `template.HTML` instead of string where appropriate
@wxiaoguangwxiaoguang added type/enhancementAn improvement of existing functionality type/featureCompletely new functionality. Can only be merged if feature freeze is not active. labelsMar 8, 2025
@wxiaoguangwxiaoguang changed the titleFix #33358 - Syntax highlighting should be full-file onlyFull-file syntax highlighting for diff pagesMar 8, 2025
@wxiaoguangwxiaoguang added type/enhancementAn improvement of existing functionality and removed type/featureCompletely new functionality. Can only be merged if feature freeze is not active. type/enhancementAn improvement of existing functionality labelsMar 8, 2025
@GiteaBotGiteaBot added lgtm/need 1This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelsMar 8, 2025
@wxiaoguangwxiaoguang removed their assignmentMar 8, 2025
@lunny
Copy link
Member

When expend more codes, it result in 500

Render failed, failed to render template: repo/diff/blob_excerpt, error: template error: builtin(static):repo/diff/blob_excerpt:83:20 : executing "repo/diff/blob_excerpt" at <$.section.GetComputedInlineDiffFor>: error calling GetComputedInlineDiffFor: runtime error: invalid memory address or nil pointer dereference----------------------------------------------------------------------{{$inlineDiff := $.section.GetComputedInlineDiffFor $line ctx.Locale}}                  ^----------------------------------------------------------------------

@wxiaoguang
Copy link
Contributor

When expend more codes, it result in 500

Fixed inb2dbc78 and added more tests

@GiteaBotGiteaBot added lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1This PR needs approval from one additional maintainer to be merged. labelsMar 9, 2025
@lunnylunny added the reviewed/wait-mergeThis pull request is part of the merge queue. It will be merged soon. labelMar 9, 2025
@wxiaoguangwxiaoguang merged commit3f1f808 intogo-gitea:mainMar 9, 2025
26 checks passed
@GiteaBotGiteaBot removed the reviewed/wait-mergeThis pull request is part of the merge queue. It will be merged soon. labelMar 9, 2025
zjjhot added a commit to zjjhot/gitea that referenced this pull requestMar 10, 2025
* giteaofficial/main:  Move notifywatch to service layer (go-gitea#33825)  [skip ci] Updated translations via Crowdin  Only keep popular licenses (go-gitea#33832)  Removing unwanted ui container (go-gitea#33833)  Full-file syntax highlighting for diff pages (go-gitea#33766)  Improve theme display (go-gitea#30671)  Decouple context from repository related structs (go-gitea#33823)  Improve log format (go-gitea#33814)  Decouple diff stats query from actual diffing (go-gitea#33810)  Add global lock for migrations to make upgrade more safe with multiple replications (go-gitea#33706)  Do not show passkey on http sites (go-gitea#33820)
hiifong pushed a commit to hiifong/gitea that referenced this pull requestMar 10, 2025
Fixgo-gitea#33358,fixgo-gitea#21970This adds a step in the `GitDiffForRender` that does syntax highlighting for theentire file and then only references lines from that syntax highlightedcode. This allows things like multi-line comments to be syntaxhighlighted correctly.---------Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>(cherry picked from commit3f1f808)
@go-giteago-gitea locked asresolvedand limited conversation to collaboratorsJun 7, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@wxiaoguangwxiaoguangwxiaoguang approved these changes

@lunnylunnylunny approved these changes

@silverwindsilverwindsilverwind approved these changes

Assignees

No one assigned

Labels

lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore.modifies/apiThis PR adds API routes or modifies themmodifies/goPull requests that update Go codemodifies/templatesThis PR modifies the template filestype/enhancementAn improvement of existing functionality

Projects

None yet

Milestone

1.24.0

Development

Successfully merging this pull request may close these issues.

Syntax highlighting should be full-file only PHP Syntax Highlighting does not working in review mode

7 participants

@dfirebaugh@wxiaoguang@silverwind@delvh@warasilapm@lunny@GiteaBot

[8]ページ先頭

©2009-2025 Movatter.jp