Skip to content

Commit b758b82

Browse files
committed
InputText: Pasting a multi-line buffer into a single-line edit replaces carriage return by spaces. (#8459)
1 parent 79bba34 commit b758b82

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

docs/CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ Other changes:
7777
inner/outer padding applied to hit-testing of windows borders and detection
7878
of hovered window.
7979
- InputText: Allow CTRL+Shift+Z to redo even outside of OSX. (#8389) [@tanksdude]
80+
- InputText: Pasting a multi-line buffer into a single-line edit replaces
81+
carriage return by spaces. (#8459)
8082
- InputTextWithHint(): Fixed buffer-overflow (luckily often with no visible effect)
8183
when a user callback modified the buffer contents in a way that altered the
8284
visibility of the preview/hint buffer. (#8368) [@m9710797, @ocornut]

imgui_widgets.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4294,7 +4294,13 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, Im
42944294
if (c < 0x20)
42954295
{
42964296
bool pass = false;
4297-
pass |= (c == '\n') && (flags & ImGuiInputTextFlags_Multiline) != 0; // Note that an Enter KEY will emit \r and be ignored (we poll for KEY in InputText() code)
4297+
pass |= (c == '\n') && (flags & ImGuiInputTextFlags_Multiline) != 0; // Note that an Enter KEY will emit \r and be ignored (we poll for KEY in InputText() code)
4298+
if (c == '\n' && input_source_is_clipboard && (flags & ImGuiInputTextFlags_Multiline) == 0) // In single line mode, replace \n with a space
4299+
{
4300+
c = *p_char = ' ';
4301+
pass = true;
4302+
}
4303+
pass |= (c == '\n') && (flags & ImGuiInputTextFlags_Multiline) != 0;
42984304
pass |= (c == '\t') && (flags & ImGuiInputTextFlags_AllowTabInput) != 0;
42994305
if (!pass)
43004306
return false;

0 commit comments

Comments
 (0)