-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix order of string in editor #10083
Fix order of string in editor #10083
Conversation
The string defined in a BibTeX file were shown in random order in the respective GUI editor. While the code already sorts them, by storing the items into a set, it destroys the order again. Fix this behaviour by storing them as a list, which retains the order.
ddad2fd
to
c24e689
Compare
BibtexString string1 = new BibtexString("TSE", "Transactions on Software Engineering"); | ||
BibtexString string2 = new BibtexString("ICSE", "International Conference on Software Engineering"); | ||
Collection<BibtexString> stringValues = List.of(string1, string2); | ||
when(db.getStringValues()).thenReturn(stringValues); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to mock the database here, you can simply create a new object without mocking e.g.
bibDatabaseContext = new BibDatabaseContext(new BibDatabase());
|
||
ListProperty<ConstantsItemModel> strings = model.stringsListProperty(); | ||
assertAll( | ||
() -> assertEquals("ICSE", strings.get(0).labelProperty().getValue()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can direclty compare the collections like this:
var strings = model.stringsLIstPrroperty.stream().map(ConstantsItemModel::labelProperty).map(StringProperty::getValue).collect(Collectors.toList());
Just assertEquals(stringValues, strings)
Thanks for the bugfix and for the creation of the test, just some minor "nitpicks" for improving the code style |
Thanks for the quick review, I've attempted to address both suggestions. Shall I squash the two commits or is it fine to leave them/done automatically during merging? |
Just push your new changes, we squash them when merging! |
Codewise looks good, but i mentioned that after adding a new string, the list is probably not sorted again. |
I've just checked, the list is not sorted after adding a new string. This will only be done by hitting the |
Took a quick look, would be nice if you could quickly implement this: Instead of void return the newly added item from |
Adding a new entry should also preserve the sorting of the strings table, thus we need to resort the entries and take care that the focus in the table is still on the newly-created entry.
I've implemented the requested reordering @calixtus in 90adb53. However, I did it a bit different than you've suggested: it's now a hook to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍. The changes need a second review and thus this PR awaits a second review.
Thanks again for your contribution! Looking forward to more ;) |
The string defined in a BibTeX file were shown in random order in the respective GUI editor. While the code already sorts them, by storing the items into a set, it destroys the order again. Fix this behaviour by storing them as a list, which retains the order.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)