VBA/VB6 code not detected in *.frm files (no syntax highlighting and not in language stats) #10413

Closed
opened 2025-11-02 09:06:48 -06:00 by GiteaMirror · 11 comments
Owner

Originally created by @King555a on GitHub (Mar 10, 2023).

Description

When uploading a VB6 (Visual Basic 6.0) project to a repository in Gitea, *.frm files, which, among others like *.bas and *.cls, contain VB6 code, these are not affecting the language statistics bar and there is no syntax highlighting. I even tried linguist-language=vb6 to override it, which changed nothing.

And I also think that the *.bas files, where syntax highlighting works, are not calculated into the statistics. I have *.bas files with many thousands of lines, but my repo is detected as 95% HTML. The HTML files have only a few hundred lines.

Sorry if this should be posted as an issue at the go-enry repo.

Gitea Version

1.18.5

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

2.39.2

Operating System

Ubuntu 18.04.6 LTS x64

How are you running Gitea?

I installed it as a package (https://gitlab.com/packaging/gitea). I also tested it at https://try.gitea.io/

Database

MySQL

Originally created by @King555a on GitHub (Mar 10, 2023). ### Description When uploading a VB6 (Visual Basic 6.0) project to a repository in Gitea, *.frm files, which, among others like *.bas and *.cls, contain VB6 code, these are not affecting the language statistics bar and there is no syntax highlighting. I even tried `linguist-language=vb6` to override it, which changed nothing. And I also think that the *.bas files, where syntax highlighting works, are not calculated into the statistics. I have *.bas files with many thousands of lines, but my repo is detected as 95% HTML. The HTML files have only a few hundred lines. Sorry if this should be posted as an issue at the go-enry repo. ### Gitea Version 1.18.5 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.39.2 ### Operating System Ubuntu 18.04.6 LTS x64 ### How are you running Gitea? I installed it as a package (https://gitlab.com/packaging/gitea). I also tested it at https://try.gitea.io/ ### Database MySQL
GiteaMirror added the type/bugtype/upstream labels 2025-11-02 09:06:48 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Mar 11, 2023):

Gitea uses https://github.com/alecthomas/chroma , it seems that Chroma doesn't support VB.

@wxiaoguang commented on GitHub (Mar 11, 2023): Gitea uses https://github.com/alecthomas/chroma , it seems that Chroma doesn't support VB.
Author
Owner

@King555a commented on GitHub (Mar 11, 2023):

Oh, OK, I thought it's go-enry. So go-enry is just for language detection and chroma for syntax highlighting? Or am I wrong with go-enry? I'm sure I've read it anywhere, but now I can't find any hint that go-enry is used.

Nevertheless some files are obviously detected as VBA, but only a few. So something is not working 100% correctly. 😉 Regarding the syntax highlighting: I guess *.bas and *.cls have the highlighting for another language (because they are highlighted, but not 100% correctly, especially *.cls).

At this point I'm unsure where to post this issue, whether it's chroma, go-enry, gitea, ...

@King555a commented on GitHub (Mar 11, 2023): Oh, OK, I thought it's go-enry. So go-enry is just for language detection and chroma for syntax highlighting? Or am I wrong with go-enry? I'm sure I've read it anywhere, but now I can't find any hint that go-enry is used. Nevertheless some files are obviously detected as VBA, but only a few. So something is not working 100% correctly. 😉 Regarding the syntax highlighting: I guess *.bas and *.cls have the highlighting for another language (because they are highlighted, but not 100% correctly, especially *.cls). At this point I'm unsure where to post this issue, whether it's chroma, go-enry, gitea, ...
Author
Owner

@wxiaoguang commented on GitHub (Mar 11, 2023):

So go-enry is just for language detection and chroma for syntax highlighting?

I think you are right 😁

At this point I'm unsure where to post this issue, whether it's chroma, go-enry, gitea, ...

A recent highlighting issue is this one, maybe it could help you.

Gitea 100% depneds on Chroma to do highlighting. It's impossible to support new languages without upstream support.

And I have experiences with VB6 in old ages. IIRC, VB6 "frm" file is not pure code file, it also contains "form definition", so maybe it needs a new parser & syntax-highlighter (from upstream ....)

The problem is, TBH, VB6 is quite old (and almost dead ...), I am not sure whether upstream could support it easily.

@wxiaoguang commented on GitHub (Mar 11, 2023): > So go-enry is just for language detection and chroma for syntax highlighting? I think you are right 😁 > At this point I'm unsure where to post this issue, whether it's chroma, go-enry, gitea, ... A recent highlighting issue is this one, maybe it could help you. * #22904 Gitea 100% depneds on Chroma to do highlighting. It's impossible to support new languages without upstream support. And I have experiences with VB6 in old ages. IIRC, VB6 "frm" file is not pure code file, it also contains "form definition", so maybe it needs a new parser & syntax-highlighter (from upstream ....) The problem is, TBH, VB6 is quite old (and almost dead ...), I am not sure whether upstream could support it easily.
Author
Owner

@King555a commented on GitHub (Mar 11, 2023):

I just created a feature request issue at Chroma: https://github.com/alecthomas/chroma/issues/762

Yes, VB6 is old, but still used quite a lot. And VBA will never be old, because there is no alternative in MS Office apps. Chroma even supports QBasic, which was probably outdated about 1995. So maybe there is a chance.

And also yes, the frm files (but not cls, bas and some others) contain the form definition first, before the real code is showing.

@King555a commented on GitHub (Mar 11, 2023): I just created a feature request issue at Chroma: https://github.com/alecthomas/chroma/issues/762 Yes, VB6 is old, but still used quite a lot. And VBA will never be old, because there is no alternative in MS Office apps. Chroma even supports QBasic, which was probably outdated about 1995. So maybe there is a chance. And also yes, the frm files (but not cls, bas and some others) contain the form definition first, before the real code is showing.
Author
Owner

@King555a commented on GitHub (Mar 14, 2023):

Apart from the syntax highlighting and possible problems with frm files, why does *.bas linguist-language=vb6 in the .gitattributes file does not affect the statistics bar? vb6 seems to be an alias for VBA in go-enry. Only the bas files have 900 KB in my case, while HTML files only have 90 KB and batch files have 0,5 KB, but this is the result:

bar

@King555a commented on GitHub (Mar 14, 2023): Apart from the syntax highlighting and possible problems with frm files, why does `*.bas linguist-language=vb6` in the `.gitattributes` file does not affect the statistics bar? `vb6` seems to be an alias for VBA in go-enry. Only the bas files have 900 KB in my case, while HTML files only have 90 KB and batch files have 0,5 KB, but this is the result: ![bar](https://user-images.githubusercontent.com/126968427/225101881-d74d469e-a718-4288-a284-a8ac29530564.png)
Author
Owner

@King555a commented on GitHub (Apr 3, 2023):

Today I saw that since version 1.19.0 my stats show 94.5% vb6, 5.2% HTML and 0.3% VBA. I don't know what files are still detected as VBA and why HTML has this large value, but it looks better than before.

But why is the language exactly like I said in the .gitattributes file (linguist-language=vb6)? I thought "vb6" is only an alias. So I would expect the "main" name (which would probably be VBA currently).

@King555a commented on GitHub (Apr 3, 2023): Today I saw that since version 1.19.0 my stats show 94.5% vb6, 5.2% HTML and 0.3% VBA. I don't know what files are still detected as VBA and why HTML has this large value, but it looks better than before. But why is the language exactly like I said in the .gitattributes file (`linguist-language=vb6`)? I thought "vb6" is only an alias. So I would expect the "main" name (which would probably be VBA currently).
Author
Owner

@wxiaoguang commented on GitHub (Apr 3, 2023):

Hmm sorry, I do not know what your repository looks like so I guess I can't provide an accurate answer.

The calculation is done by:

// GetLanguageStats calculates language stats for git repository at specified commit
func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, error)

You can take a look if you have interests. And without a reproducible example (the real repository), I guess it's difficult to figure out what it should be.

@wxiaoguang commented on GitHub (Apr 3, 2023): Hmm sorry, I do not know what your repository looks like so I guess I can't provide an accurate answer. The calculation is done by: ``` // GetLanguageStats calculates language stats for git repository at specified commit func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, error) ``` You can take a look if you have interests. And without a reproducible example (the real repository), I guess it's difficult to figure out what it should be.
Author
Owner

@King555a commented on GitHub (Apr 3, 2023):

Seems like the percent values are correct. I created a test repository (https://try.gitea.io/hdfiushfdidf/vb6-test) and got (almost) the same values. I also manually calculated it and it's correct. I could not believe that the HTML files are such big compared to the VB6 files. My bad.

But there must have been a change in 1.19.0. It wasn't calculated correctly before. That's good, of course, but there is also the change that the value of linguist-language is now taken literally. You can see it in the linked repository.

According to go-enry, vb6 should show as VBA, if I'm not misunderstanding it:

        399230729: LanguageInfo{
	Name:   "VBA",
	FSName: "",
	Type:   TypeForString("programming"),
	Color:  "#867db1",
	Group:  "",
	Aliases: []string{
		"vb6",
		"visual basic 6",
		"visual basic for applications",
	},

Also the color is wrong now. Maybe the alias names are not working at all?

@King555a commented on GitHub (Apr 3, 2023): Seems like the percent values are correct. I created a test repository (https://try.gitea.io/hdfiushfdidf/vb6-test) and got (almost) the same values. I also manually calculated it and it's correct. I could not believe that the HTML files are such big compared to the VB6 files. My bad. But there must have been a change in 1.19.0. It wasn't calculated correctly before. That's good, of course, but there is also the change that the value of `linguist-language` is now taken literally. You can see it in the linked repository. According to go-enry, `vb6` should show as `VBA`, if I'm not misunderstanding it: 399230729: LanguageInfo{ Name: "VBA", FSName: "", Type: TypeForString("programming"), Color: "#867db1", Group: "", Aliases: []string{ "vb6", "visual basic 6", "visual basic for applications", }, Also the color is wrong now. Maybe the alias names are not working at all?
Author
Owner

@wxiaoguang commented on GitHub (Apr 4, 2023):

The color is provided by

// LoadAttributes loads attributes
func (stats LanguageStatList) LoadAttributes() {
	for i := range stats {
		stats[i].Color = enry.GetColor(stats[i].Language)
	}
}

If the language name is not recognized, then you see different colors.

@wxiaoguang commented on GitHub (Apr 4, 2023): The color is provided by ``` // LoadAttributes loads attributes func (stats LanguageStatList) LoadAttributes() { for i := range stats { stats[i].Color = enry.GetColor(stats[i].Language) } } ``` If the language name is not recognized, then you see different colors.
Author
Owner

@King555a commented on GitHub (Apr 4, 2023):

I just checked in my test repo and obviously I cannot use the alias names. The alias "xhtml" for "HTML" also does not work.

Should I report this at the go-enry repository?

@King555a commented on GitHub (Apr 4, 2023): I just checked in my test repo and obviously I cannot use the alias names. The alias "xhtml" for "HTML" also does not work. Should I report this at the go-enry repository?
Author
Owner

@wxiaoguang commented on GitHub (Apr 4, 2023):

Yup if it's related to upstream

@wxiaoguang commented on GitHub (Apr 4, 2023): Yup if it's related to upstream
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10413