Skip to content

Conversation

@DawydowGerman
Copy link

@DawydowGerman DawydowGerman commented Dec 7, 2025

Closes #14403

Addressed in this PR:

Steps to test

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • [/] I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2025

Hey @DawydowGerman! 👋

Thank you for contributing to JabRef!

We have automated checks in place, based on which you will soon get feedback if any of them are failing.

After all automated checks pass, a maintainer will also review your contribution. Once that happens, you can go through their comments in the "Files changed" tab and act on them, or reply to the conversation if you have further inputs.

Please re-check our AI Usage Policy to ensure that your pull request is in line with it. It also contains links to our contribution guide in case of any other doubts related to our contribution workflow.

@github-actions github-actions bot added first contrib status: changes-required Pull requests that are not yet complete labels Dec 7, 2025
@koppor
Copy link
Member

koppor commented Dec 8, 2025

@DawydowGerman it seems you rebased instead of merging..

To start with a clean commit we have following advice

Rebase everything as one commit on main

  • Precondition: JabRef/jabref is configured as upstream.
  • Fetch recent commits and prune non-existing branches: git fetch upstream --prune
  • Merge recent commits: git merge upstream/main
  • If there are conflicts, resolve them
  • Reset index to upstream/main: git reset upstream/main
  • Review the changes and create a new commit using git gui: git gui
  • Do a force push: git push -f origin

See also: https://help.github.com/articles/syncing-a-fork/

@DawydowGerman
Copy link
Author

@koppor, thank you for advice. I'll try to fix the issue.

* Remove defaults map filling
* Add getAutoCompletePreferencesFromBackingStore method
* Add getAutoCompletePreferencesFromBackingStore call to getAutoCompletePreferences method
* Add getAutoCompletePreferences calls to clear, importPreferences methods
* Add private constructor, setAll, getDefault methods


---------

Co-authored-by: Carl Christian Snethlage <[email protected]>
Co-authored-by: Oliver Kopp <[email protected]>
@DawydowGerman DawydowGerman force-pushed the DawydowGerman-fix-for-issue-14403 branch from 4e1b6e7 to 077b7f7 Compare December 8, 2025 20:01
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 9, 2025
Comment on lines +1233 to +1237
.stream()
.map(Field::getName)
.collect(Collectors.joining(";"));
String completeFieldsFromPrefsNode = get(AUTOCOMPLETER_COMPLETE_FIELDS, completeFields);
Set<Field> completeFieldsSet = Stream.of(completeFieldsFromPrefsNode.split(";"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please modify getStringList method. Introduce parseStringList method or sthg, but do not introduce magic strings in high level code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean something like that:

    // Add 2 methods in JabRefCliPreferences class
    static Set<Field> convertStringToFieldSet(String toConvert) {
        return Stream.of(toConvert.split(";"))
                     .map(String::trim)
                     .filter(s -> !s.isEmpty())
                     .map(String::toUpperCase)
                     .map(name -> {
                         try {
                             return StandardField.valueOf(name);
                         } catch (IllegalArgumentException e) {
                             return null;
                         }
                     })
                     .filter(Objects::nonNull)
                     .collect(Collectors.toCollection(HashSet::new));
    }
    
    public Set<Field> getFieldSet(String key, ObservableSet<Field> def) {
        try {
            return convertStringToFieldSet(get(key));
        } catch (NullPointerException e) {
            return new HashSet<>(def);
        }
    }
    
    // in getDonationPreferencesFromBackingStore method remains getFieldSet call 
   // instead of that complex snippet (18 lines of parsing/converting)
    return new AutoCompletePreferences(getBoolean(AUTO_COMPLETE, defaults.shouldAutoComplete()),
        firstNameMode,
        nameFormat,
        getFieldSet(AUTOCOMPLETER_COMPLETE_FIELDS, defaults.getCompleteFields()));```

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK, we have to check:

  1. Is there any similar functionality already existing somewhere in JabRef. For instance, I found: org.jabref.model.entry.field.FieldFactory#parseFieldList - I found it whlie searching for ; in the class at hand. - I am not sure why the ordering is destroyed by your code. Shouldn't the ordering be kept.
  2. Please do NOT use null. You can use Flatmatp.

Copy link
Member

@calixtus calixtus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 10, 2025
Copy link
Member

@calixtus calixtus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable resetting of AutoCompletePreferences

3 participants