diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 8828e28ec..384863e51 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -89,6 +89,9 @@ Other Changes: would be incorrect during the deactivation frame. (#9298) - Fixed a crash introduced in 1.92.6 when handling ImGuiInputTextFlags_CallbackResize 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: - Border sizes are now scaled (and rounded) by ScaleAllSizes(). - When using large values with ScallAllSizes(), the following items thickness diff --git a/imgui.h b/imgui.h index 0086c60a3..e4f4f5d8a 100644 --- a/imgui.h +++ b/imgui.h @@ -30,7 +30,7 @@ // Library Version // (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_NUM 19265 +#define IMGUI_VERSION_NUM 19266 #define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000 #define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198 diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 8a2ab9f31..3c980b86c 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4588,6 +4588,7 @@ static int InputTextLineIndexBuild(ImGuiInputTextFlags flags, ImGuiTextIndex* li ImGuiContext& g = *GImGui; int size = 0; const char* s; + bool trailing_line_already_counted = false; if (flags & ImGuiInputTextFlags_WordWrap) { for (s = buf; s < buf_end; s = (*s == '\n') ? s + 1 : s) @@ -4608,6 +4609,7 @@ static int InputTextLineIndexBuild(ImGuiInputTextFlags flags, ImGuiTextIndex* li } else { + // Inactive path: we don't know buf_end ahead of time. const char* s_eol; 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) continue; s += strlen(s); + trailing_line_already_counted = true; break; } } @@ -4626,7 +4629,7 @@ static int InputTextLineIndexBuild(ImGuiInputTextFlags flags, ImGuiTextIndex* li line_index->Offsets.push_back(0); 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)); size++;