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

Register index update listener #11317

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where imports to a custom group would only work for the first entry [#11085](https://github.com/JabRef/jabref/issues/11085), [#11269](https://github.com/JabRef/jabref/issues/11269)
- We fixed an issue where a new entry was not added to the selected group [#8933](https://github.com/JabRef/jabref/issues/8933)
- We fixed an issue where the horizontal position of the Entry Preview inside the entry editor was not remembered across restarts [#11281](https://github.com/JabRef/jabref/issues/11281)
- We fixed an issue where the search index was not updated after linking PDF files. [#11317](https://github.com/JabRef/jabref/pull/11317)
- We fixed an issue where the entry editor context menu was not shown correctly when JabRef is opened on a second, extended screen [#11323](https://github.com/JabRef/jabref/issues/11323), [#11174](https://github.com/JabRef/jabref/issues/11174)

### Removed
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ private void setDatabaseContext(BibDatabaseContext bibDatabaseContext) {
setupMainPanel();
setupAutoCompletion();

this.getDatabase().registerListener(new IndexUpdateListener());
this.getDatabase().registerListener(new EntriesRemovedListener());

// ensure that at each addition of a new entry, the entry is added to the groups interface
Expand Down Expand Up @@ -1085,9 +1086,9 @@ public void listen(FieldChangedEvent fieldChangedEvent) {
List<LinkedFile> newFileList = FileFieldParser.parse(fieldChangedEvent.getNewValue());

List<LinkedFile> addedFiles = new ArrayList<>(newFileList);
addedFiles.remove(oldFileList);
addedFiles.removeAll(oldFileList);
List<LinkedFile> removedFiles = new ArrayList<>(oldFileList);
removedFiles.remove(newFileList);
removedFiles.removeAll(newFileList);

try {
PdfIndexer indexer = PdfIndexerManager.getIndexer(bibDatabaseContext, preferencesService.getFilePreferences());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ public Path getFulltextIndexPath() {
Path indexPath;

if (getDatabasePath().isPresent()) {
Path databaseFileName = getDatabasePath().get().getFileName();
String fileName = BackupFileUtil.getUniqueFilePrefix(databaseFileName) + "--" + databaseFileName;
Path databasePath = getDatabasePath().get();
String fileName = BackupFileUtil.getUniqueFilePrefix(databasePath) + "--" + databasePath.getFileName();
indexPath = appData.resolve(fileName);
LOGGER.debug("Index path for {} is {}", getDatabasePath().get(), indexPath);
return indexPath;
Expand Down
Loading