Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting incorrect in Diff for PascalObject #33354

Open
NeeeeB opened this issue Jan 22, 2025 · 6 comments
Open

Syntax highlighting incorrect in Diff for PascalObject #33354

NeeeeB opened this issue Jan 22, 2025 · 6 comments
Labels
type/bug type/upstream This is an issue in one of Gitea's dependencies and should be reported there

Comments

@NeeeeB
Copy link

NeeeeB commented Jan 22, 2025

Description

There is a problem with colors and syntax highlighting in diff for PascalObject language (maybe other too, didn't try).
This is what the diff looks like :

Image
As you can see, the 2 lines of comments (beginning with //) are not treated as comments.

The problem is not present in the code explorer where comments are properly detected :

Image

Gitea Version

1.23.1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

package manager (Arch) so systemD

Database

None

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jan 22, 2025

The reason is this: #19684 (comment) and #21970

  • Full file highlighting: guess the syntax by file content
  • Diff highlighting: only use the file extension (then maybe it is rendered as traditional pascal but not object pascal) and highlight line by line

(Just a guess) maybe we could hard code all *.pas to use object pascal syntax as a workaround.

@wxiaoguang
Copy link
Contributor

Hmm, it is a upstream bug: alecthomas/chroma#1042

@wxiaoguang wxiaoguang added the type/upstream This is an issue in one of Gitea's dependencies and should be reported there label Jan 22, 2025
@NeeeeB
Copy link
Author

NeeeeB commented Jan 22, 2025

Yup, I was gonna reply that comments in Pascal and ObjectPascal are the same, //
Thanks for opening that issue in Chroma.

@silverwind
Copy link
Member

silverwind commented Jan 22, 2025

Opened #33358 for discussing a general fix.

@wxiaoguang
Copy link
Contributor

Opened #33358 for discussing a general fix.

This is another case than #33358 , this case could be fixed by upstream

@silverwind
Copy link
Member

silverwind commented Jan 23, 2025

Yeah, that's why i left this open. A general solution with the full-file syntax highlight would also fix this issue assuming the file has more than one line and a trailing newline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug type/upstream This is an issue in one of Gitea's dependencies and should be reported there
Projects
None yet
Development

No branches or pull requests

3 participants