mirror of https://github.com/helix-editor/helix
Don't replace newlines
parent
2e4a338944
commit
c349ceb61f
|
@ -466,19 +466,20 @@ pub fn replace(cx: &mut Context) {
|
||||||
..
|
..
|
||||||
} = event
|
} = event
|
||||||
{
|
{
|
||||||
let text = Tendril::from_char(ch);
|
|
||||||
|
|
||||||
let (view, doc) = cx.current();
|
let (view, doc) = cx.current();
|
||||||
|
|
||||||
let transaction =
|
let transaction =
|
||||||
Transaction::change_by_selection(doc.text(), doc.selection(view.id), |range| {
|
Transaction::change_by_selection(doc.text(), doc.selection(view.id), |range| {
|
||||||
let max_to = doc.text().len_chars().saturating_sub(1);
|
let max_to = doc.text().len_chars().saturating_sub(1);
|
||||||
let to = std::cmp::min(max_to, range.to() + 1);
|
let to = std::cmp::min(max_to, range.to() + 1);
|
||||||
(
|
let text: String = doc
|
||||||
range.from(),
|
.text()
|
||||||
to,
|
.slice(range.from()..to)
|
||||||
Some(text.repeat(to - range.from()).into()),
|
.chars()
|
||||||
)
|
.map(|c| if c == '\n' { '\n' } else { ch })
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
(range.from(), to, Some(text.as_str().into()))
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.apply(&transaction, view.id);
|
doc.apply(&transaction, view.id);
|
||||||
|
|
Loading…
Reference in New Issue