Skip to content

Commit

Permalink
Refactor GenerateCandidatePages method to rectify width calculation l…
Browse files Browse the repository at this point in the history
…ogic
  • Loading branch information
doyaGu committed Jan 17, 2025
1 parent 130a0d9 commit 4dbfe9c
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/CommandBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,10 @@ void CommandBar::GenerateCandidatePages() {

for (int i = 0; i < (int) m_Candidates.size(); ++i) {
const ImVec2 size = ImGui::CalcTextSize(m_Candidates[i].c_str());
// Add indicator widths if it's not the first page
float effectiveMax = max;
if (m_CandidatePages.size() > 1) {
effectiveMax -= pager * 2; // Reserve space for "< " and " >"
}

width += size.x + sep;
if (width > effectiveMax) {
if (width > max) {
m_CandidatePages.push_back(i); // Start a new page
width = size.x - sep + pager * 2; // Reset width with indicators
width = size.x - sep + pager * 2;
}
}
}
Expand Down

0 comments on commit 4dbfe9c

Please sign in to comment.