BCad fork

C++ Patches (ImGuiColorTextEdit)
Login

C++ Patches (ImGuiColorTextEdit)

Patch file: cpp/imgui/imgui_color_text_edit.patch

All patches are local modifications to TextEditor.cpp. The git submodule (external/ImGuiColorTextEdit/) should NOT be committed — only the patch file and the local copy at cpp/imgui_bundle/ track these changes.

Hunk 1: updateState() — don't override cursor visibility

scrollToLine() from updateState() (called when typesetter layout changes) would override a pending ensureVisiblePos set by makeCursorVisible(). Fix: guard with if (ensureVisiblePos.line == invalidLine).

Hunk 2: scrollToLine() — don't clear ensureVisiblePos

Removed ensureVisiblePos = DocPos(invalidLine, 0) so that makeCursorVisible() and scrollToLine() can coexist. The cursor-visibility scroll is processed first in handlePossibleScrolling(), then the line-scroll is processed — without this removal, scrollToLine() would wipe the cursor scroll before it was processed.

Hunk 3: handlePossibleScrolling() — remove scrollX = 0.0f

Removed scrollX = 0.0f reset in the scrollToLineNumber block, so horizontal scroll position is preserved when scrolling to a line.

Hunk 4: handleCharacter() — always call makeCursorVisible() after text insert

makeCursorVisible() was previously only called inside the isWord(character) block (for autocomplete). For '\n' (Enter), the cursor moved to a new line but no visibility check ran. Fix: always call makeCursorVisible() after endTransaction(), then handle autocomplete separately.