From 4bd3771fd32c9973ce4da992e0ec2f5afec7e5df Mon Sep 17 00:00:00 2001 From: Anish Pal <55245782+pal-anish@users.noreply.github.com> Date: Thu, 1 Feb 2024 15:22:25 +0530 Subject: [PATCH] Fix Suggestion Provider for Crossref during autocompletion disable (#10829) * #8145 Fix Suggestion Provider for Crossref during autocompletion disable * #8145 Fix Test Cases Related Issue * #8145 Removed unwanted commented code * #8145 Added Changelog.md file --------- Co-authored-by: Anish.Pal --- CHANGELOG.md | 1 + src/main/java/org/jabref/gui/LibraryTab.java | 4 ++-- .../jabref/gui/autocompleter/SuggestionProviders.java | 9 +++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e91f5ae991..c83a4906cc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - The last page of a PDF is now indexed by the full text search. [#10193](https://github.com/JabRef/jabref/issues/10193) - We fixed an issue where the duplicate check did not take umlauts or other LaTeX-encoded characters into account. [#10744](https://github.com/JabRef/jabref/pull/10744) - We fixed the colors of the icon on hover for unset special fields. [#10431](https://github.com/JabRef/jabref/issues/10431) +- We fixed an issue where the CrossRef field did not work if autocompletion was disabled [#8145](https://github.com/JabRef/jabref/issues/8145) ### Removed diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java index ea00153a7a4..66b1c4588ec 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -568,8 +568,8 @@ private void setupAutoCompletion() { if (autoCompletePreferences.shouldAutoComplete()) { suggestionProviders = new SuggestionProviders(getDatabase(), Globals.journalAbbreviationRepository, autoCompletePreferences); } else { - // Create empty suggestion providers if auto-completion is deactivated - suggestionProviders = new SuggestionProviders(); + // Create suggestion providers with database for crossref if auto-completion is deactivated + suggestionProviders = new SuggestionProviders(getDatabase()); } searchAutoCompleter = new PersonNameSuggestionProvider(FieldFactory.getPersonNameFields(), getDatabase()); } diff --git a/src/main/java/org/jabref/gui/autocompleter/SuggestionProviders.java b/src/main/java/org/jabref/gui/autocompleter/SuggestionProviders.java index 06d2abef8a8..7d023f4d815 100644 --- a/src/main/java/org/jabref/gui/autocompleter/SuggestionProviders.java +++ b/src/main/java/org/jabref/gui/autocompleter/SuggestionProviders.java @@ -22,12 +22,21 @@ public SuggestionProviders(BibDatabase database, JournalAbbreviationRepository a this.isEmpty = false; } + public SuggestionProviders(BibDatabase database) { + this.database = database; + this.isEmpty = true; + } + public SuggestionProviders() { this.isEmpty = true; } public SuggestionProvider getForField(Field field) { if (isEmpty || !autoCompletePreferences.getCompleteFields().contains(field)) { + Set fieldProperties = field.getProperties(); + if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK)) { + return new BibEntrySuggestionProvider(database); + } return new EmptySuggestionProvider(); }