command palette: fixed recent files history bug

This commit is contained in:
YohananDiamond 2023-07-31 15:07:10 -03:00
parent 8b8f90893e
commit 00ee72269f

View file

@ -44,6 +44,7 @@ void FurnaceGUI::drawPalette() {
g->paletteFirstFrame=true; g->paletteFirstFrame=true;
g->paletteQuery=""; g->paletteQuery="";
g->curPaletteChoice=0; g->curPaletteChoice=0;
g->paletteSearchResults.clear();
}; };
bool accepted=false; bool accepted=false;
@ -69,7 +70,7 @@ void FurnaceGUI::drawPalette() {
case CMDPAL_TYPE_RECENT: case CMDPAL_TYPE_RECENT:
for (int i=0; i<(int)recentFile.size(); i++) { for (int i=0; i<(int)recentFile.size(); i++) {
if (matchFuzzy(recentFile[i].c_str(),paletteQuery.c_str())) { if (matchFuzzy(recentFile.at(i).c_str(),paletteQuery.c_str())) {
paletteSearchResults.push_back(i); paletteSearchResults.push_back(i);
} }
} }
@ -106,13 +107,15 @@ void FurnaceGUI::drawPalette() {
s=guiActions[id].friendlyName; s=guiActions[id].friendlyName;
break; break;
case CMDPAL_TYPE_RECENT: case CMDPAL_TYPE_RECENT:
s=recentFile[id].c_str(); s=recentFile.at(id).c_str();
break; break;
default: default:
logE("invalid command palette type"); logE("invalid command palette type");
break; break;
}; };
logD("~ %d, %d", curPaletteType, s == nullptr);
if (ImGui::Selectable(s,current)) { if (ImGui::Selectable(s,current)) {
curPaletteChoice=i; curPaletteChoice=i;
accepted=true; accepted=true;
@ -133,6 +136,10 @@ void FurnaceGUI::drawPalette() {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
// do not move this to after the resetPalette() calls!
// if they are called before and we're jumping from one palette to the next, the paletteFirstFrame won't be true at the start and the setup will not happen.
paletteFirstFrame=false;
if (accepted) { if (accepted) {
if (paletteSearchResults.size()==0) { if (paletteSearchResults.size()==0) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
@ -149,7 +156,7 @@ void FurnaceGUI::drawPalette() {
case CMDPAL_TYPE_RECENT: case CMDPAL_TYPE_RECENT:
resetPalette(this); resetPalette(this);
openRecentFile(recentFile[i]); openRecentFile(recentFile.at(i));
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
break; break;
@ -160,6 +167,4 @@ void FurnaceGUI::drawPalette() {
}; };
} }
} }
paletteFirstFrame=false;
} }