Skip to content

Fix chroma lexer mapping#36629

Merged
silverwind merged 3 commits into
go-gitea:mainfrom
wxiaoguang:fix-diff-chroma-lexer
Feb 16, 2026
Merged

Fix chroma lexer mapping#36629
silverwind merged 3 commits into
go-gitea:mainfrom
wxiaoguang:fix-diff-chroma-lexer

Conversation

@wxiaoguang
Copy link
Copy Markdown
Contributor

Fix some edge cases for ".hcl" and ".v" files, and add more tests

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 14, 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 15, 2026
@silverwind
Copy link
Copy Markdown
Member

Comment written by Claude (AI assistant)

I reviewed this PR. The changes look correct and well-structured. A few observations:

What the PR does well:

  1. The new conflictingAliasLangMap cleanly mirrors the existing conflictingExtLangMap pattern — one handles file extension conflicts, the other handles language name/alias conflicts. This is a consistent design.

  2. The extracted processLexerNameAliases function adds proper conflict detection with panics on unexpected duplicates. This is important because without it, the last lexer registered for a given alias silently wins, which is non-deterministic and could change between Chroma versions.

  3. The panic-based validation at init time (both for unexpected conflicts and for the final consistency check) is the right approach — it catches misconfigurations immediately at startup rather than producing subtly wrong highlighting at runtime.

  4. The test coverage is thorough. The split into casesWithContent (testing the full detectChromaLexerWithAnalyze pipeline) and casesNameLang (testing detectChromaLexerByFileName directly, including the byLang return value) makes the different detection layers easy to reason about. The .hcl case is particularly well-tested since it exercises the full conflict resolution path: ext map → Terraform, then enry → "HCL", then alias map → HCL lexer.

  5. The rename from setMapWithLowerKey to setFileNameMapWithLowerKey improves clarity since there's now a separate path for name/alias processing.

LGTM

@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 16, 2026
@silverwind
Copy link
Copy Markdown
Member

Wow, first time I see Claude not complaining about anything 😆.

@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 16, 2026
@silverwind silverwind enabled auto-merge (squash) February 16, 2026 01:33
@silverwind silverwind merged commit 258754f into go-gitea:main Feb 16, 2026
24 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Feb 16, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 16, 2026
@wxiaoguang wxiaoguang deleted the fix-diff-chroma-lexer branch February 16, 2026 02:18
silverwind pushed a commit to Excellencedev/gitea that referenced this pull request Feb 17, 2026
Fix some edge cases for ".hcl" and ".v" files, and add more tests
@go-gitea go-gitea locked as resolved and limited conversation to collaborators May 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants