Skip to content

Refactor highlight and diff#36599

Merged
wxiaoguang merged 4 commits intogo-gitea:mainfrom
wxiaoguang:refactor-highlight
Feb 13, 2026
Merged

Refactor highlight and diff#36599
wxiaoguang merged 4 commits intogo-gitea:mainfrom
wxiaoguang:refactor-highlight

Conversation

@wxiaoguang
Copy link
Copy Markdown
Contributor

@wxiaoguang wxiaoguang commented Feb 12, 2026

  1. fix a performance regression when using line-by-line highlighting
    • the root cause is that chroma's lexers.Get is slow and a lexer cache is missing during recent changes
  2. clarify the chroma lexer detection behavior
    • now we fully manage our logic to detect lexer, and handle overriding problems, everything is fully under control
  3. clarify "code analyze" behavior, now only 2 usages:
    • only use file name and language to detect lexer (very fast), mainly for "diff" page which contains a lot of files
    • if no lexer is detected by file name and language, use code content to detect again (slow), mainly for "view file" or "blame" page, which can get best result
  4. fix git diff bug, it caused "broken pipe" error for large diff files

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 12, 2026
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Feb 12, 2026
@wxiaoguang wxiaoguang force-pushed the refactor-highlight branch 4 times, most recently from df43d0d to f25a8d0 Compare February 12, 2026 11:30
@wxiaoguang wxiaoguang requested a review from Copilot February 12, 2026 13:02
@wxiaoguang wxiaoguang changed the title Refactor highlight module Refactor highlight and diff Feb 12, 2026

This comment was marked as resolved.

This comment was marked as resolved.

@wxiaoguang wxiaoguang added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label Feb 12, 2026
@wxiaoguang wxiaoguang added this to the 1.26.0 milestone Feb 12, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 12, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 12, 2026
@wxiaoguang wxiaoguang enabled auto-merge (squash) February 12, 2026 23:44
@wxiaoguang wxiaoguang merged commit 0d8bd77 into go-gitea:main Feb 13, 2026
24 checks passed
@wxiaoguang wxiaoguang deleted the refactor-highlight branch February 13, 2026 01:23
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 14, 2026
* origin/main: (2555 commits)
  automate updating nix flakes (go-gitea#35641)
  Update AGENTS.md instructions (go-gitea#36627)
  use user id in noreply emails (go-gitea#36550)
  feat(db): Improve BuildCaseInsensitiveLike with lowercase (go-gitea#36598)
  [skip ci] Updated translations via Crowdin
  BUG: Fix workflow run jobs API returning null steps (go-gitea#36603)
  Refactor highlight and diff (go-gitea#36599)
  Fix bug when do LFS GC (go-gitea#36500)
  feature to be able to filter project boards by milestones (go-gitea#36321)
  Update emoji data for Unicode 16 (go-gitea#36596)
  Adapt monaco error matching pattern to recent webpack config change (go-gitea#36533)
  Fix a bug user could change another user's primary email (go-gitea#36586)
  fix(repo-editor): disable Monaco `editContext` to avoid bugs with lost focus (go-gitea#36585)
  Fine tune diff highlighting (go-gitea#36592)
  Add code editor setting dropdowns (go-gitea#36534)
  Update to go 1.26.0 and golangci-lint 2.9.0 (go-gitea#36588)
  Improve diff highlighting (go-gitea#36583)
  Fix markup code block layout (go-gitea#36578)
  Remove striped tables in UI (go-gitea#36509)
  Fix vertical alignment of `.commit-sign-badge` children (go-gitea#36570)
  ...

# Conflicts:
#	custom/conf/app.example.ini
#	docs/content/administration/config-cheat-sheet.en-us.md
#	docs/content/administration/config-cheat-sheet.zh-cn.md
#	modules/setting/security.go
#	routers/common/errpage.go
#	services/context/api.go
#	services/context/context.go
Sirherobrine23 pushed a commit to Sirherobrine23/gitea that referenced this pull request Mar 4, 2026
1. fix a performance regression when using line-by-line highlighting
* the root cause is that chroma's `lexers.Get` is slow and a lexer cache
is missing during recent changes
2. clarify the chroma lexer detection behavior
* now we fully manage our logic to detect lexer, and handle overriding
problems, everything is fully under control
3. clarify "code analyze" behavior, now only 2 usages:
* only use file name and language to detect lexer (very fast), mainly
for "diff" page which contains a lot of files
* if no lexer is detected by file name and language, use code content to
detect again (slow), mainly for "view file" or "blame" page, which can
get best result
4. fix git diff bug, it caused "broken pipe" error for large diff files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants