attribute autocomplete should show prefix matches first and only after matches anywhere, #1284

This commit is contained in:
zadam 2020-10-03 22:00:34 +02:00
parent 0c4deda091
commit 1a262fe680

View File

@ -109,7 +109,16 @@ function getAttributeNames(type, nameLike) {
}
}
names.sort();
names.sort((a, b) => {
const aPrefix = a.toLowerCase().startsWith(nameLike);
const bPrefix = b.toLowerCase().startsWith(nameLike);
if (aPrefix !== bPrefix) {
return aPrefix ? -1 : 1;
}
return a < b ? -1 : 1;
});
return names;
}