Fix GUI paste of CRLF/CR text: split all line endings

The ImGui Cmd+V/Ctrl+V paste handler split clipboard text only on '\n',
leaving '\r' inside each segment. Pasting text with CRLF (Windows) or bare
CR (classic-Mac / some macOS apps) line endings enqueued an InsertText arg
containing '\r', which the InsertText command rejects with "InsertText arg
must not contain newlines".

Extract the paste-to-commands logic into a pure, SDL-free helper
(PasteSplit.h) that treats '\n', '\r\n', and bare '\r' each as one line
break, and add unit tests covering all line-ending forms plus blank-line
and trailing-newline preservation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-03 00:20:36 -07:00
co-authored by Claude Opus 4.8
parent 3126a5e523
commit 480f1390c7
4 changed files with 160 additions and 26 deletions
+2 -1
View File
@@ -4,7 +4,7 @@ project(kte)
include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD 20)
set(KTE_VERSION "1.11.2")
set(KTE_VERSION "1.11.3")
# Default to terminal-only build to avoid SDL/OpenGL dependency by default.
# Enable with -DBUILD_GUI=ON when SDL2/OpenGL/Freetype are available.
@@ -345,6 +345,7 @@ if (BUILD_TESTS)
tests/test_smart_newline.cc
tests/test_reflow_undo.cc
tests/test_syntax_highlighting.cc
tests/test_paste_split.cc
# minimal engine sources required by Buffer
PieceTable.cc