Fix incorrect language selected in language selector (#21648)

Due to filtering after enumeration, initial candidate ids are assigned
incorrectly. This later causes the wrong item to be picked up when
accessed via index in the vector.
This commit is contained in:
tims 2024-12-06 22:33:58 +05:30 committed by GitHub
parent 304158ed79
commit e5251f4091
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -104,14 +104,15 @@ impl LanguageSelectorDelegate {
let candidates = language_registry
.language_names()
.into_iter()
.enumerate()
.filter_map(|(candidate_id, name)| {
.filter_map(|name| {
language_registry
.available_language_for_name(&name)?
.hidden()
.not()
.then(|| StringMatchCandidate::new(candidate_id, name))
.then_some(name)
})
.enumerate()
.map(|(candidate_id, name)| StringMatchCandidate::new(candidate_id, name))
.collect::<Vec<_>>();
Self {