Fixed an issue where the 'Jump to..' quick selector wouldn't work correctly for multi-byte Unicode characters.

This commit is contained in:
Leon Styhre 2022-05-09 20:21:39 +02:00
parent 53ad5a3152
commit 7b07ccb44d

View file

@ -488,16 +488,16 @@ void GuiGamelistOptions::openMetaDataEd()
void GuiGamelistOptions::jumpToLetter() void GuiGamelistOptions::jumpToLetter()
{ {
char letter {mJumpToLetterList->getSelected().front()}; std::string letter {Utils::String::getFirstCharacter(mJumpToLetterList->getSelected())};
// Get the gamelist. // Get the gamelist.
const std::vector<FileData*>& files = const std::vector<FileData*>& files {
getGamelist()->getCursor()->getParent()->getChildrenListToDisplay(); getGamelist()->getCursor()->getParent()->getChildrenListToDisplay()};
for (unsigned int i = 0; i < files.size(); ++i) { for (unsigned int i = 0; i < files.size(); ++i) {
if (mFavoritesSorting && (mFirstLetterIndex.front() == ViewController::FAVORITE_CHAR || if (mFavoritesSorting && (mFirstLetterIndex.front() == ViewController::FAVORITE_CHAR ||
mFirstLetterIndex.front() == ViewController::FOLDER_CHAR)) { mFirstLetterIndex.front() == ViewController::FOLDER_CHAR)) {
if (static_cast<char>(toupper(files.at(i)->getSortName().front())) == letter && if (Utils::String::getFirstCharacter(files.at(i)->getSortName()) == letter &&
!files.at(i)->getFavorite()) { !files.at(i)->getFavorite()) {
if (!mOnlyHasFolders && mFoldersOnTop && files.at(i)->getType() == FOLDER) { if (!mOnlyHasFolders && mFoldersOnTop && files.at(i)->getType() == FOLDER) {
continue; continue;
@ -509,7 +509,7 @@ void GuiGamelistOptions::jumpToLetter()
} }
} }
else { else {
if (static_cast<char>(toupper(files.at(i)->getSortName().front())) == letter) { if (Utils::String::getFirstCharacter(files.at(i)->getSortName()) == letter) {
if (!mOnlyHasFolders && mFoldersOnTop && files.at(i)->getType() == FOLDER) { if (!mOnlyHasFolders && mFoldersOnTop && files.at(i)->getType() == FOLDER) {
continue; continue;
} }