diff options
author | Wojciech Kępka | 2021-06-07 19:28:04 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-08 08:23:38 +0000 |
commit | c349ceb61f7af9e90db7a58d2305da239157ae63 (patch) | |
tree | 6a4c3f7b39af8991198c0fc0fc56eedaf4e5efb7 /helix-term/src | |
parent | 2e4a338944d31e77b4db5dd7d578aacedef3256f (diff) |
Don't replace newlines
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/commands.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 94e1af2d..0e39f0f2 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -466,19 +466,20 @@ pub fn replace(cx: &mut Context) { .. } = event { - let text = Tendril::from_char(ch); - let (view, doc) = cx.current(); let transaction = Transaction::change_by_selection(doc.text(), doc.selection(view.id), |range| { let max_to = doc.text().len_chars().saturating_sub(1); let to = std::cmp::min(max_to, range.to() + 1); - ( - range.from(), - to, - Some(text.repeat(to - range.from()).into()), - ) + let text: String = doc + .text() + .slice(range.from()..to) + .chars() + .map(|c| if c == '\n' { '\n' } else { ch }) + .collect(); + + (range.from(), to, Some(text.as_str().into())) }); doc.apply(&transaction, view.id); |