Return sorted definitions for file names and mime types
ClosedPublic

Authored by davschul on Feb 21 2019, 1:56 PM.

Diff Detail

Repository
R216 Syntax Highlighting
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
davschul created this revision.Feb 21 2019, 1:56 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptFeb 21 2019, 1:56 PM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
davschul requested review of this revision.Feb 21 2019, 1:56 PM
cullmann accepted this revision.Feb 21 2019, 2:14 PM

Yes, this is nice, nice trick with value(0) to avoid adding an element to the vector but just letting the API default construct it.

This revision is now accepted and ready to land.Feb 21 2019, 2:14 PM
This revision was automatically updated to reflect the committed changes.
cullmann reopened this revision.Feb 21 2019, 2:19 PM

Beside that this fails ;=)

This revision is now accepted and ready to land.Feb 21 2019, 2:19 PM

The partial sort is bad ;=()

I think one error is the sort of the empty vector with the begin() + 1
But even then, make test fails, after fixing this.
Please take a look and run the tests.
Thanks

cullmann requested changes to this revision.Feb 21 2019, 2:28 PM
This revision now requires changes to proceed.Feb 21 2019, 2:28 PM

I think the + 1 is the only real issue, the other issue stems from my local setting that I have no compiled in QRC.

Actually, do we need a partial sort? Should we not just stable_sort the complete vector by prio? That should keep stuff with same prio untouched, or?

Ah sorry completely missed that part. Unfortunately I'm out of office already, I'll take a look as soon as I'm back tomorrow.

dhaumann added inline comments.
src/lib/repository.cpp
83

Isn't std::stable_sort what we want here?

Thanks for taking a look again ;=)

I would propose to just stable_sort the vector, that should always yield the same result.
And I think the sorting is the only issue, the other problem I got did only occur with non-QRC syntax files and was introduced by myself ;=)

davschul updated this revision to Diff 52268.Feb 22 2019, 6:37 AM

Yeah, I just missed to recheck the sorting logic. Before the change we just needed the best match so the partial sort was completely sufficient. Now we need a complete sorted vector, so stable sort is the way to go ;)

cullmann accepted this revision.Feb 22 2019, 7:53 AM

Ok, this seems to work now here, too ;) Will merge it, thanks again.

This revision is now accepted and ready to land.Feb 22 2019, 7:53 AM
This revision was automatically updated to reflect the committed changes.

Cool, thanks! ...which now leads us to the point where the only missing part is a unit test for the two new public functions :-)