@@ -466,19 +466,20 @@ pub fn replace(cx: &mut Context) {
466466 ..
467467 } = event
468468 {
469− let text = Tendril::from_char(ch);
470−
471469 let (view, doc) = cx.current();
472470
473471 let transaction =
474472 Transaction::change_by_selection(doc.text(), doc.selection(view.id), |range| {
475473 let max_to = doc.text().len_chars().saturating_sub(1);
476474 let to = std::cmp::min(max_to, range.to() + 1);
477− (
478− range.from(),
479− to,
480− Some(text.repeat(to - range.from()).into()),
481− )
475+ let text: String = doc
476+ .text()
477+ .slice(range.from()..to)
478+ .chars()
479+ .map(|c| if c == '\n' { '\n' } else { ch })
480+ .collect();
481+
482+ (range.from(), to, Some(text.as_str().into()))
482483 });
483484
484485 doc.apply(&transaction, view.id);