The manual includes this section describing how to start a tag file:
The first line of global tags files should be a comment, introduced by # followed by a space and a string like format=pipe, format=ctags or format=tagmanager respectively, these are case-sensitive. This helps Geany to read the file properly. If this line is missing, Geany tries to auto-detect the used format but this might fail.
This is wrong for ctags files because after reading the ```# format=ctags``` line the file is rewinded. And then ctags parsing aborts on the very first line because it is expecting a different format. It only skips ```!_TAG_``` lines.
On recognizing ```!_TAG_``` lines the tag file format is set to ```TM_FILE_FORMAT_CTAGS``` so tag file authors should be instructed to only use such lines for ```ctags``` files and not lines starting with ```#```.
Just to confirm, by "ctags parsing aborts" you actually mean loading the ctags file into Geany?
Yes. If you have a ```# ``` comment line in a ctags file it aborts and just writes "0 symbols imported" in the debug messages.
Why doesn't [this](https://github.com/geany/geany/blob/7c6b4794b1c0f9696465fb8920ccffc107f5b4d8...) line work?
That line works.
But then comes the rewind in https://github.com/geany/geany/blob/master/src/tagmanager/tm_source_file.c#L... and the tags will later be imported like this:
In ```new_tag_from_tags_file``` the function ```init_tag_from_file_ctags``` will be called because the detected format is ```ctags```. And in the loop at https://github.com/geany/geany/blob/master/src/tagmanager/tm_source_file.c#L... it "only" skips the ```!_TAG_``` lines. Please remember, the file has been reverted back to the start. Therefore the skiping loop breaks at the first ```#``` comment line and tries to read it in as a tag definition line, which fails of course.
Ahh, ok so for the case of `# format=ctags` we should move the file forward over the first line after the rewind, and then the reader will not see that.
Yes, if we see it as a bug in the code, otherwise adjust the manual....
Good catch, and thanks for the investigation!
Closed #1814 via #1817.
github-comments@lists.geany.org