From 2a726c7136912709001e7bdaccd41415cbcf7ab2 Mon Sep 17 00:00:00 2001 From: SparkyTD <45818400+SparkyTD@users.noreply.github.com> Date: Sat, 11 May 2024 09:11:14 -0700 Subject: [PATCH] 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) --- .../imgui/ColorTextEditor/source/TextEditor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/third_party/imgui/ColorTextEditor/source/TextEditor.cpp b/lib/third_party/imgui/ColorTextEditor/source/TextEditor.cpp index 10cd8abe0..6ceb3387f 100644 --- a/lib/third_party/imgui/ColorTextEditor/source/TextEditor.cpp +++ b/lib/third_party/imgui/ColorTextEditor/source/TextEditor.cpp @@ -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) {