From 429dfd7467e739c3225e2d691307a93d584ae9f1 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Wed, 24 Jun 2026 16:50:05 +0200 Subject: [PATCH] new: Prefer e.data to capture the exact inserted character(s) from key entry --- AppKit/CPTextView/CPTextView.j | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 82589bb2c..d5ef34ffb 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -3187,10 +3187,12 @@ var _CPCopyPlaceholder = '-'; _CPNativeInputField.innerHTML = ''; return; } - - // Robustness: Use 'textContent' instead of 'innerHTML' to strip any - // unexpected HTML tags the browser might have inserted. - var textToInsert = e.target.textContent; + + // Prefer e.data to capture the exact inserted character(s) from key entry. + // This avoids harvesting structural markup or stale carriage returns + // introduced by the browser's selection layout. + var textToInsert = (e.data !== undefined && e.data !== null) ? e.data : e.target.textContent; + handleInput(textToInsert); });