Skip to content

Commit a2f3d03

Browse files
committed
dep/imgui: Update to 69a501d
1 parent ace6cd2 commit a2f3d03

15 files changed

+3459
-1986
lines changed

dep/imgui/include/imconfig.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#pragma once
1616

1717
//---- Define assertion handler. Defaults to calling assert().
18-
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
18+
// - If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
19+
// - Compiling with NDEBUG will usually strip out assert() to nothing, which is NOT recommended because we use asserts to notify of programmer mistakes.
1920
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
2021
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
2122

@@ -83,6 +84,7 @@
8384

8485
//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
8586
// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
87+
// Note that imgui_freetype.cpp may be used _without_ this define, if you manually call ImFontAtlas::SetFontLoader(). The define is simply a convenience.
8688
// On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'.
8789
#define IMGUI_ENABLE_FREETYPE
8890

@@ -129,6 +131,10 @@
129131
//#define IM_DEBUG_BREAK IM_ASSERT(0)
130132
//#define IM_DEBUG_BREAK __debugbreak()
131133

134+
//---- Debug Tools: Enable highlight ID conflicts _before_ hovering items. When io.ConfigDebugHighlightIdConflicts is set.
135+
// (THIS WILL SLOW DOWN DEAR IMGUI. Only use occasionally and disable after use)
136+
//#define IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS
137+
132138
//---- Debug Tools: Enable slower asserts
133139
//#define IMGUI_DEBUG_PARANOID
134140

dep/imgui/include/imgui.h

Lines changed: 217 additions & 145 deletions
Large diffs are not rendered by default.

dep/imgui/include/imgui_freetype.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Usage:
99
// - Add '#define IMGUI_ENABLE_FREETYPE' in your imconfig to automatically enable support
1010
// for imgui_freetype in imgui. It is equivalent to selecting the default loader with:
11-
// io.Fonts.FontLoader = ImGuiFreeType::GetFontLoader()
11+
// io.Fonts->SetFontLoader(ImGuiFreeType::GetFontLoader())
1212

1313
// Optional support for OpenType SVG fonts:
1414
// - Add '#define IMGUI_ENABLE_FREETYPE_PLUTOSVG' to use plutosvg (not provided). See #7927.
@@ -62,7 +62,7 @@ namespace ImGuiFreeType
6262
{
6363
// This is automatically assigned when using '#define IMGUI_ENABLE_FREETYPE'.
6464
// If you need to dynamically select between multiple builders:
65-
// - you can manually assign this builder with 'atlas->FontLoader = ImGuiFreeType::GetFontLoader()'
65+
// - you can manually assign this builder with 'atlas->SetFontLoader(ImGuiFreeType::GetFontLoader())'
6666
// - prefer deep-copying this into your own ImFontLoader instance if you use hot-reloading that messes up static data.
6767
IMGUI_API const ImFontLoader* GetFontLoader();
6868

@@ -75,7 +75,7 @@ namespace ImGuiFreeType
7575

7676
// Obsolete names (will be removed)
7777
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
78-
//IMGUI_API const ImFontBuilderIO* GetBuilderForFreeType(); // Renamed/changed in 1.92. Change 'io.Fonts->FontBuilderIO = ImGuiFreeType::GetBuilderForFreeType()' to 'io.Fonts.FontLoader = ImGuiFreeType::GetFontLoader()' if you need runtime selection.
78+
//IMGUI_API const ImFontBuilderIO* GetBuilderForFreeType(); // Renamed/changed in 1.92. Change 'io.Fonts->FontBuilderIO = ImGuiFreeType::GetBuilderForFreeType()' to 'io.Fonts->SetFontLoader(ImGuiFreeType::GetFontLoader())' if you need runtime selection.
7979
//static inline bool BuildFontAtlas(ImFontAtlas* atlas, unsigned int flags = 0) { atlas->FontBuilderIO = GetBuilderForFreeType(); atlas->FontLoaderFlags = flags; return atlas->Build(); } // Prefer using '#define IMGUI_ENABLE_FREETYPE'
8080
#endif
8181
}

dep/imgui/include/imgui_internal.h

Lines changed: 257 additions & 172 deletions
Large diffs are not rendered by default.

dep/imgui/include/imgui_stdlib.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
2+
23
// This is also an example of how you may wrap your own similar types.
4+
// TL;DR; this is using the ImGuiInputTextFlags_CallbackResize facility,
5+
// which also demonstrated in 'Dear ImGui Demo->Widgets->Text Input->Resize Callback'.
36

47
// Changelog:
58
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
69

10+
// Usage:
11+
// {
12+
// #include "misc/cpp/imgui_stdlib.h"
13+
// #include "misc/cpp/imgui_stdlib.cpp" // <-- If you want to include implementation without messing with your project/build.
14+
// [...]
15+
// std::string my_string;
16+
// ImGui::InputText("my string", &my_string);
17+
// }
18+
719
// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
820
// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness
921

dep/imgui/include/imstb_textedit.h

Lines changed: 75 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// - Fix in stb_textedit_find_charpos to handle last line (see https://github.com/ocornut/imgui/issues/6000 + #6783)
66
// - Added name to struct or it may be forward declared in our code.
77
// - Added UTF-8 support (see https://github.com/nothings/stb/issues/188 + https://github.com/ocornut/imgui/pull/7925)
8-
// Grep for [DEAR IMGUI] to find the changes.
8+
// - Changed STB_TEXTEDIT_INSERTCHARS() to return inserted count (instead of 0/1 bool), allowing partial insertion.
9+
// Grep for [DEAR IMGUI] to find some changes.
910
// - Also renamed macros used or defined outside of IMSTB_TEXTEDIT_IMPLEMENTATION block from STB_TEXTEDIT_* to IMSTB_TEXTEDIT_*
1011

1112
// stb_textedit.h - v1.14 - public domain - Sean Barrett
@@ -39,6 +40,7 @@
3940
//
4041
// VERSION HISTORY
4142
//
43+
// !!!! (2025-10-23) changed STB_TEXTEDIT_INSERTCHARS() to return inserted count (instead of 0/1 bool), allowing partial insertion.
4244
// 1.14 (2021-07-11) page up/down, various fixes
4345
// 1.13 (2019-02-07) fix bug in undo size management
4446
// 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash
@@ -147,7 +149,8 @@
147149
// as manually wordwrapping for end-of-line positioning
148150
//
149151
// STB_TEXTEDIT_DELETECHARS(obj,i,n) delete n characters starting at i
150-
// STB_TEXTEDIT_INSERTCHARS(obj,i,c*,n) insert n characters at i (pointed to by STB_TEXTEDIT_CHARTYPE*)
152+
// STB_TEXTEDIT_INSERTCHARS(obj,i,c*,n) try to insert n characters at i (pointed to by STB_TEXTEDIT_CHARTYPE*)
153+
// returns number of characters actually inserted. [DEAR IMGUI]
151154
//
152155
// STB_TEXTEDIT_K_SHIFT a power of two that is or'd in to a keyboard input to represent the shift key
153156
//
@@ -181,10 +184,10 @@
181184
//
182185
// To support UTF-8:
183186
//
184-
// STB_TEXTEDIT_GETPREVCHARINDEX returns index of previous character
185-
// STB_TEXTEDIT_GETNEXTCHARINDEX returns index of next character
187+
// STB_TEXTEDIT_GETPREVCHARINDEX returns index of previous character
188+
// STB_TEXTEDIT_GETNEXTCHARINDEX returns index of next character
186189
// Do NOT define STB_TEXTEDIT_KEYTOTEXT.
187-
// Instead, call stb_textedit_text() directly for text contents.
190+
// Instead, call stb_textedit_text() directly for text contents.
188191
//
189192
// Keyboard input must be encoded as a single integer value; e.g. a character code
190193
// and some bitflags that represent shift states. to simplify the interface, SHIFT must
@@ -260,7 +263,7 @@
260263
//
261264
// text: (added 2025)
262265
// call this to directly send text input the textfield, which is required
263-
// for UTF-8 support, because stb_textedit_key() + STB_TEXTEDIT_KEYTOTEXT()
266+
// for UTF-8 support, because stb_textedit_key() + STB_TEXTEDIT_KEYTOTEXT()
264267
// cannot infer text length.
265268
//
266269
//
@@ -427,7 +430,7 @@ typedef struct
427430
//
428431

429432
// traverse the layout to locate the nearest character to a display position
430-
static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
433+
static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y, int* out_side_on_line)
431434
{
432435
StbTexteditRow r;
433436
int n = STB_TEXTEDIT_STRINGLEN(str);
@@ -437,6 +440,7 @@ static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
437440
r.x0 = r.x1 = 0;
438441
r.ymin = r.ymax = 0;
439442
r.num_chars = 0;
443+
*out_side_on_line = 0;
440444

441445
// search rows to find one that straddles 'y'
442446
while (i < n) {
@@ -456,7 +460,10 @@ static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
456460

457461
// below all text, return 'after' last character
458462
if (i >= n)
463+
{
464+
*out_side_on_line = 1;
459465
return n;
466+
}
460467

461468
// check if it's before the beginning of the line
462469
if (x < r.x0)
@@ -469,6 +476,7 @@ static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
469476
for (k=0; k < r.num_chars; k = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, i + k) - i) {
470477
float w = STB_TEXTEDIT_GETWIDTH(str, i, k);
471478
if (x < prev_x+w) {
479+
*out_side_on_line = (k == 0) ? 0 : 1;
472480
if (x < prev_x+w/2)
473481
return k+i;
474482
else
@@ -480,6 +488,7 @@ static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
480488
}
481489

482490
// if the last character is a newline, return that. otherwise return 'after' the last character
491+
*out_side_on_line = 1;
483492
if (STB_TEXTEDIT_GETCHAR(str, i+r.num_chars-1) == STB_TEXTEDIT_NEWLINE)
484493
return i+r.num_chars-1;
485494
else
@@ -491,23 +500,26 @@ static void stb_textedit_click(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *st
491500
{
492501
// In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
493502
// goes off the top or bottom of the text
503+
int side_on_line;
494504
if( state->single_line )
495505
{
496506
StbTexteditRow r;
497507
STB_TEXTEDIT_LAYOUTROW(&r, str, 0);
498508
y = r.ymin;
499509
}
500510

501-
state->cursor = stb_text_locate_coord(str, x, y);
511+
state->cursor = stb_text_locate_coord(str, x, y, &side_on_line);
502512
state->select_start = state->cursor;
503513
state->select_end = state->cursor;
504514
state->has_preferred_x = 0;
515+
str->LastMoveDirectionLR = (ImS8)(side_on_line ? ImGuiDir_Right : ImGuiDir_Left);
505516
}
506517

507518
// API drag: on mouse drag, move the cursor and selection endpoint to the clicked location
508519
static void stb_textedit_drag(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
509520
{
510521
int p = 0;
522+
int side_on_line;
511523

512524
// In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
513525
// goes off the top or bottom of the text
@@ -521,8 +533,9 @@ static void stb_textedit_drag(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *sta
521533
if (state->select_start == state->select_end)
522534
state->select_start = state->cursor;
523535

524-
p = stb_text_locate_coord(str, x, y);
536+
p = stb_text_locate_coord(str, x, y, &side_on_line);
525537
state->cursor = state->select_end = p;
538+
str->LastMoveDirectionLR = (ImS8)(side_on_line ? ImGuiDir_Right : ImGuiDir_Left);
526539
}
527540

528541
/////////////////////////////////////////////////////////////////////////////
@@ -572,6 +585,8 @@ static void stb_textedit_find_charpos(StbFindState *find, IMSTB_TEXTEDIT_STRING
572585
STB_TEXTEDIT_LAYOUTROW(&r, str, i);
573586
if (n < i + r.num_chars)
574587
break;
588+
if (str->LastMoveDirectionLR == ImGuiDir_Right && str->Stb->cursor > 0 && str->Stb->cursor == i + r.num_chars && STB_TEXTEDIT_GETCHAR(str, i + r.num_chars - 1) != STB_TEXTEDIT_NEWLINE) // [DEAR IMGUI] Wrapping point handling
589+
break;
575590
if (i + r.num_chars == z && z > 0 && STB_TEXTEDIT_GETCHAR(str, z - 1) != STB_TEXTEDIT_NEWLINE) // [DEAR IMGUI] special handling for last line
576591
break; // [DEAR IMGUI]
577592
prev_start = i;
@@ -668,6 +683,35 @@ static void stb_textedit_move_to_last(IMSTB_TEXTEDIT_STRING *str, STB_TexteditSt
668683
}
669684
}
670685

686+
// [DEAR IMGUI] Extracted this function so we can more easily add support for word-wrapping.
687+
#ifndef STB_TEXTEDIT_MOVELINESTART
688+
static int stb_textedit_move_line_start(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int cursor)
689+
{
690+
if (state->single_line)
691+
return 0;
692+
while (cursor > 0) {
693+
int prev = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, cursor);
694+
if (STB_TEXTEDIT_GETCHAR(str, prev) == STB_TEXTEDIT_NEWLINE)
695+
break;
696+
cursor = prev;
697+
}
698+
return cursor;
699+
}
700+
#define STB_TEXTEDIT_MOVELINESTART stb_textedit_move_line_start
701+
#endif
702+
#ifndef STB_TEXTEDIT_MOVELINEEND
703+
static int stb_textedit_move_line_end(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int cursor)
704+
{
705+
int n = STB_TEXTEDIT_STRINGLEN(str);
706+
if (state->single_line)
707+
return n;
708+
while (cursor < n && STB_TEXTEDIT_GETCHAR(str, cursor) != STB_TEXTEDIT_NEWLINE)
709+
cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, cursor);
710+
return cursor;
711+
}
712+
#define STB_TEXTEDIT_MOVELINEEND stb_textedit_move_line_end
713+
#endif
714+
671715
#ifdef STB_TEXTEDIT_IS_SPACE
672716
static int is_word_boundary( IMSTB_TEXTEDIT_STRING *str, int idx )
673717
{
@@ -734,7 +778,8 @@ static int stb_textedit_paste_internal(IMSTB_TEXTEDIT_STRING *str, STB_TexteditS
734778
stb_textedit_clamp(str, state);
735779
stb_textedit_delete_selection(str,state);
736780
// try to insert the characters
737-
if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len)) {
781+
len = STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len);
782+
if (len) {
738783
stb_text_makeundo_insert(state, state->cursor, len);
739784
state->cursor += len;
740785
state->has_preferred_x = 0;
@@ -759,13 +804,15 @@ static void stb_textedit_text(IMSTB_TEXTEDIT_STRING* str, STB_TexteditState* sta
759804
if (state->insert_mode && !STB_TEXT_HAS_SELECTION(state) && state->cursor < STB_TEXTEDIT_STRINGLEN(str)) {
760805
stb_text_makeundo_replace(str, state, state->cursor, 1, 1);
761806
STB_TEXTEDIT_DELETECHARS(str, state->cursor, 1);
762-
if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, text_len)) {
807+
text_len = STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, text_len);
808+
if (text_len) {
763809
state->cursor += text_len;
764810
state->has_preferred_x = 0;
765811
}
766812
} else {
767813
stb_textedit_delete_selection(str, state); // implicitly clamps
768-
if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, text_len)) {
814+
text_len = STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, text_len);
815+
if (text_len) {
769816
stb_text_makeundo_insert(state, state->cursor, text_len);
770817
state->cursor += text_len;
771818
state->has_preferred_x = 0;
@@ -921,8 +968,8 @@ static void stb_textedit_key(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *stat
921968

922969
// [DEAR IMGUI]
923970
// going down while being on the last line shouldn't bring us to that line end
924-
if (STB_TEXTEDIT_GETCHAR(str, find.first_char + find.length - 1) != STB_TEXTEDIT_NEWLINE)
925-
break;
971+
//if (STB_TEXTEDIT_GETCHAR(str, find.first_char + find.length - 1) != STB_TEXTEDIT_NEWLINE)
972+
// break;
926973

927974
// now find character position down a row
928975
state->cursor = start;
@@ -943,6 +990,8 @@ static void stb_textedit_key(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *stat
943990
}
944991
stb_textedit_clamp(str, state);
945992

993+
if (state->cursor == find.first_char + find.length)
994+
str->LastMoveDirectionLR = ImGuiDir_Left;
946995
state->has_preferred_x = 1;
947996
state->preferred_x = goal_x;
948997

@@ -1007,6 +1056,10 @@ static void stb_textedit_key(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *stat
10071056
}
10081057
stb_textedit_clamp(str, state);
10091058

1059+
if (state->cursor == find.first_char)
1060+
str->LastMoveDirectionLR = ImGuiDir_Right;
1061+
else if (state->cursor == find.prev_first)
1062+
str->LastMoveDirectionLR = ImGuiDir_Left;
10101063
state->has_preferred_x = 1;
10111064
state->preferred_x = goal_x;
10121065

@@ -1024,7 +1077,7 @@ static void stb_textedit_key(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *stat
10241077
prev_scan = prev;
10251078
}
10261079
find.first_char = find.prev_first;
1027-
find.prev_first = prev_scan;
1080+
find.prev_first = STB_TEXTEDIT_MOVELINESTART(str, state, prev_scan);
10281081
}
10291082
break;
10301083
}
@@ -1098,24 +1151,17 @@ static void stb_textedit_key(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *stat
10981151
case STB_TEXTEDIT_K_LINESTART:
10991152
stb_textedit_clamp(str, state);
11001153
stb_textedit_move_to_first(state);
1101-
if (state->single_line)
1102-
state->cursor = 0;
1103-
else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE)
1104-
state->cursor = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, state->cursor);
1154+
state->cursor = STB_TEXTEDIT_MOVELINESTART(str, state, state->cursor);
11051155
state->has_preferred_x = 0;
11061156
break;
11071157

11081158
#ifdef STB_TEXTEDIT_K_LINEEND2
11091159
case STB_TEXTEDIT_K_LINEEND2:
11101160
#endif
11111161
case STB_TEXTEDIT_K_LINEEND: {
1112-
int n = STB_TEXTEDIT_STRINGLEN(str);
11131162
stb_textedit_clamp(str, state);
1114-
stb_textedit_move_to_first(state);
1115-
if (state->single_line)
1116-
state->cursor = n;
1117-
else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE)
1118-
state->cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, state->cursor);
1163+
stb_textedit_move_to_last(str, state);
1164+
state->cursor = STB_TEXTEDIT_MOVELINEEND(str, state, state->cursor);
11191165
state->has_preferred_x = 0;
11201166
break;
11211167
}
@@ -1126,10 +1172,7 @@ static void stb_textedit_key(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *stat
11261172
case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT:
11271173
stb_textedit_clamp(str, state);
11281174
stb_textedit_prep_selection_at_cursor(state);
1129-
if (state->single_line)
1130-
state->cursor = 0;
1131-
else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE)
1132-
state->cursor = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, state->cursor);
1175+
state->cursor = STB_TEXTEDIT_MOVELINESTART(str, state, state->cursor);
11331176
state->select_end = state->cursor;
11341177
state->has_preferred_x = 0;
11351178
break;
@@ -1138,13 +1181,9 @@ static void stb_textedit_key(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *stat
11381181
case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT:
11391182
#endif
11401183
case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: {
1141-
int n = STB_TEXTEDIT_STRINGLEN(str);
11421184
stb_textedit_clamp(str, state);
11431185
stb_textedit_prep_selection_at_cursor(state);
1144-
if (state->single_line)
1145-
state->cursor = n;
1146-
else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE)
1147-
state->cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, state->cursor);
1186+
state->cursor = STB_TEXTEDIT_MOVELINEEND(str, state, state->cursor);
11481187
state->select_end = state->cursor;
11491188
state->has_preferred_x = 0;
11501189
break;
@@ -1319,7 +1358,7 @@ static void stb_text_undo(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
13191358
// check type of recorded action:
13201359
if (u.insert_length) {
13211360
// easy case: was a deletion, so we need to insert n characters
1322-
STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length);
1361+
u.insert_length = STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length);
13231362
s->undo_char_point -= u.insert_length;
13241363
}
13251364

@@ -1370,7 +1409,7 @@ static void stb_text_redo(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
13701409

13711410
if (r.insert_length) {
13721411
// easy case: need to insert n characters
1373-
STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length);
1412+
r.insert_length = STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length);
13741413
s->redo_char_point += r.insert_length;
13751414
}
13761415

0 commit comments

Comments
 (0)