InputTextMultiline: fixed an issue calculating lines count when inactive, no word-wrap, and ending with a \n.
Some checks failed
build / Build - Windows (push) Has been cancelled
build / Build - Linux (push) Has been cancelled
build / Build - MacOS (push) Has been cancelled
build / Build - iOS (push) Has been cancelled
build / Build - Emscripten (push) Has been cancelled
build / Build - Android (push) Has been cancelled
build / Test - Windows (push) Has been cancelled
build / Test - Linux (push) Has been cancelled
scheduled / scheduled (push) Has been cancelled

Amend 1e52e7b90c (#3237, #952, #1062, #7363)
This commit is contained in:
ocornut
2026-03-18 20:10:14 +01:00
parent 6abe65aac6
commit 4252275c64
3 changed files with 8 additions and 2 deletions

View File

@@ -89,6 +89,9 @@ Other Changes:
would be incorrect during the deactivation frame. (#9298) would be incorrect during the deactivation frame. (#9298)
- Fixed a crash introduced in 1.92.6 when handling ImGuiInputTextFlags_CallbackResize - Fixed a crash introduced in 1.92.6 when handling ImGuiInputTextFlags_CallbackResize
in certain situations. (#9174) in certain situations. (#9174)
- InputTextMultiline: fixed an issue introduced in 1.92.3 where line count calculated
for vertical scrollbar range would be +1 when the widget is inactive, word-wrap is
disabled and the text buffer ends with '\n'.
- Style: - Style:
- Border sizes are now scaled (and rounded) by ScaleAllSizes(). - Border sizes are now scaled (and rounded) by ScaleAllSizes().
- When using large values with ScallAllSizes(), the following items thickness - When using large values with ScallAllSizes(), the following items thickness

View File

@@ -30,7 +30,7 @@
// Library Version // Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
#define IMGUI_VERSION "1.92.7 WIP" #define IMGUI_VERSION "1.92.7 WIP"
#define IMGUI_VERSION_NUM 19265 #define IMGUI_VERSION_NUM 19266
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000 #define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198 #define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198

View File

@@ -4588,6 +4588,7 @@ static int InputTextLineIndexBuild(ImGuiInputTextFlags flags, ImGuiTextIndex* li
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
int size = 0; int size = 0;
const char* s; const char* s;
bool trailing_line_already_counted = false;
if (flags & ImGuiInputTextFlags_WordWrap) if (flags & ImGuiInputTextFlags_WordWrap)
{ {
for (s = buf; s < buf_end; s = (*s == '\n') ? s + 1 : s) for (s = buf; s < buf_end; s = (*s == '\n') ? s + 1 : s)
@@ -4608,6 +4609,7 @@ static int InputTextLineIndexBuild(ImGuiInputTextFlags flags, ImGuiTextIndex* li
} }
else else
{ {
// Inactive path: we don't know buf_end ahead of time.
const char* s_eol; const char* s_eol;
for (s = buf; ; s = s_eol + 1) for (s = buf; ; s = s_eol + 1)
{ {
@@ -4616,6 +4618,7 @@ static int InputTextLineIndexBuild(ImGuiInputTextFlags flags, ImGuiTextIndex* li
if ((s_eol = strchr(s, '\n')) != NULL) if ((s_eol = strchr(s, '\n')) != NULL)
continue; continue;
s += strlen(s); s += strlen(s);
trailing_line_already_counted = true;
break; break;
} }
} }
@@ -4626,7 +4629,7 @@ static int InputTextLineIndexBuild(ImGuiInputTextFlags flags, ImGuiTextIndex* li
line_index->Offsets.push_back(0); line_index->Offsets.push_back(0);
size++; size++;
} }
if (buf_end > buf && buf_end[-1] == '\n' && size <= max_output_buffer_size) if (buf_end > buf && buf_end[-1] == '\n' && size <= max_output_buffer_size && !trailing_line_already_counted)
{ {
line_index->Offsets.push_back((int)(buf_end - buf)); line_index->Offsets.push_back((int)(buf_end - buf));
size++; size++;