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

Report errors for duplicate BibTeX entry keys #904

Merged
merged 1 commit into from
Jul 23, 2023

Conversation

pfoerster
Copy link
Member

No description provided.

@pfoerster pfoerster marked this pull request as ready for review July 23, 2023 13:27
@pfoerster pfoerster merged commit 449ec7a into master Jul 23, 2023
5 checks passed
@pfoerster pfoerster deleted the feature/duplicate-entry-diagnostic branch July 23, 2023 13:27
@clason
Copy link
Contributor

clason commented Jul 23, 2023

Nice! Do duplicate labels next 🙏 :)

@clason
Copy link
Contributor

clason commented Jul 23, 2023

I just tested this (sorry for not doing so earlier!) and noticed a small nit: If you have duplicate keys, it will only report the error on one of them (the first one in the file?) If it's not hard to implement, it would be even more useful if it marked all of them, so you can check them easily and see if it's a duplicate entry or an accidental ambiguity (say, two different papers that happen to have the same authors and year).

@pfoerster
Copy link
Member Author

If you have duplicate keys, it will only report the error on one of them (the first one in the file?)

Yes, that's intentional. The Diagnostic should have the relatedInformation field populated with the additional occurences of the duplicate key. Maybe, Neovim is not showing it. Here is, how it looks like in VSCode:

image

@clason
Copy link
Contributor

clason commented Jul 23, 2023

Ah, I see. As far as I know, Neovim is indeed not doing anything with that field. It would be nice to be able to annotate the duplicate information in the file itself, to be honest. (I also feel that this is a bit unintuitive, since in your example, the actual error is actually on lines 3 and 5, not on line 1?)

@pfoerster
Copy link
Member Author

Maybe, it's easier to report one error for each entry and then link the duplicates via relatedInformation (and do the same thing for labels).

@clason
Copy link
Contributor

clason commented Jul 23, 2023

I feel that would be the best approach. But it's not a deal-breaker either way! Being able to see any error before trying to compile a huge file (and trashing your aux file in the process) is a huge quality of life gain :)

(If you have multiple bib files, duplicate keys could be in separate files, so this would make sure every file with errors gets marked as such.)

@pfoerster
Copy link
Member Author

@clason I have created a new PR: #908 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants