1
0
mirror of synced 2025-02-17 18:59:21 +01:00

fix: TextEditor line numbers were still partially rendered despite mShowLineNumbers being set to false (#1669)

### Problem description
TextEditor line numbers were still partially rendered despite
mShowLineNumbers being set to false

### Implementation description
I wrapped the line no. rendering code in `if (mShowLineNumbers) { ...
}`.

### Screenshots
Before:

![image](https://github.com/WerWolv/ImHex/assets/45818400/58a2cfdd-1ee0-484b-ba05-6e886ad4fd65)

After:

![image](https://github.com/WerWolv/ImHex/assets/45818400/5d204e2b-12a5-4fc9-bcfc-da6b8e6359e1)
This commit is contained in:
SparkyTD 2024-05-11 09:11:14 -07:00 committed by GitHub
parent 62aea46c61
commit 2a726c7136
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -914,10 +914,12 @@ void TextEditor::Render() {
}
// Draw line number (right aligned)
snprintf(buf, 16, "%d ", lineNo + 1);
if (mShowLineNumbers) {
snprintf(buf, 16, "%d ", lineNo + 1);
auto lineNoWidth = ImGui::GetFont()->CalcTextSizeA(ImGui::GetFontSize(), FLT_MAX, -1.0f, buf, nullptr, nullptr).x;
drawList->AddText(ImVec2(lineStartScreenPos.x + mTextStart - lineNoWidth, lineStartScreenPos.y), mPalette[(int)PaletteIndex::LineNumber], buf);
auto lineNoWidth = ImGui::GetFont()->CalcTextSizeA(ImGui::GetFontSize(), FLT_MAX, -1.0f, buf, nullptr, nullptr).x;
drawList->AddText(ImVec2(lineStartScreenPos.x + mTextStart - lineNoWidth, lineStartScreenPos.y), mPalette[(int)PaletteIndex::LineNumber], buf);
}
// Draw breakpoints
if (mBreakpoints.count(lineNo + 1) != 0) {