InputText: fixed cursor positioning issue using up/down keys on non-ASCII text. (#8635, #7925)

Bug introduced in abd07f6d30.
Ref https://github.com/nothings/stb/issues/188
This commit is contained in:
ocornut
2025-05-14 11:35:38 +02:00
parent 08689c51a9
commit 61242e2e6a
3 changed files with 11 additions and 5 deletions

View File

@@ -76,6 +76,8 @@ Other changes:
- The feature is unlikely to ever work properly when using a coarse clipper
such as ImGuiListClipper.
- TreeNode: fixed incorrect clipping of arrow/bullet when using ImGuiTreeNodeFlags_SpanAllColumns.
- InputText: fixed cursor positioning issue using up/down keys near end of lines while
editing non-ASCII text. (Regression from 1.91.2) (#8635, #7925)
- Tables: fixed TableHeader() eager vertical clipping of text which may be noticeable
with FramePadding.y was too small. (#6236)
- Tables: fixed an assert when combining Tables, Frozen Rows, Clipper and BeginMultiSelect()

View File

@@ -29,7 +29,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.0 WIP"
#define IMGUI_VERSION_NUM 19194
#define IMGUI_VERSION_NUM 19195
#define IMGUI_HAS_TABLE
/*

View File

@@ -918,7 +918,7 @@ retry:
state->cursor = start;
STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor);
x = row.x0;
for (i=0; i < row.num_chars; ++i) {
for (i=0; i < row.num_chars; ) {
float dx = STB_TEXTEDIT_GETWIDTH(str, start, i);
#ifdef IMSTB_TEXTEDIT_GETWIDTH_NEWLINE
if (dx == IMSTB_TEXTEDIT_GETWIDTH_NEWLINE)
@@ -927,7 +927,9 @@ retry:
x += dx;
if (x > goal_x)
break;
state->cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, state->cursor);
int next_cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, state->cursor);
i += next_cursor - state->cursor;
state->cursor = next_cursor;
}
stb_textedit_clamp(str, state);
@@ -980,7 +982,7 @@ retry:
state->cursor = find.prev_first;
STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor);
x = row.x0;
for (i=0; i < row.num_chars; ++i) {
for (i=0; i < row.num_chars; ) {
float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i);
#ifdef IMSTB_TEXTEDIT_GETWIDTH_NEWLINE
if (dx == IMSTB_TEXTEDIT_GETWIDTH_NEWLINE)
@@ -989,7 +991,9 @@ retry:
x += dx;
if (x > goal_x)
break;
state->cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, state->cursor);
int next_cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, state->cursor);
i += next_cursor - state->cursor;
state->cursor = next_cursor;
}
stb_textedit_clamp(str, state);