Skip to content

Commit

Permalink
Fix CommandBar width calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
doyaGu committed Jan 16, 2025
1 parent 1b825eb commit 9c7b9e7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/CommandBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,16 @@ size_t CommandBar::OnCompletion(const char *lineStart, const char *lineEnd) {
}
}

const float max = m_WindowSize.x;
const ImVec2 sepSize = ImGui::CalcTextSize(" | ");
float width = 0;
const float max = m_WindowSize.x - 2 * sepSize.x;
float width = -sepSize.x;
m_CandidatePages.push_back(0);
for (int i = 0; i < (int) m_Candidates.size(); ++i) {
const ImVec2 size = ImGui::CalcTextSize(m_Candidates[i].c_str());
width += size.x + sepSize.x;
if (width > max) {
m_CandidatePages.push_back(i);
width = sepSize.x;
width = 0;
}
}
} else {
Expand Down

0 comments on commit 9c7b9e7

Please sign in to comment.