From 491137995c62a7771e7f554f8c181b53b0670a49 Mon Sep 17 00:00:00 2001 From: Gareth Widlansky <101901964+gerblesh@users.noreply.github.com> Date: Mon, 30 Jun 2025 11:33:11 -0700 Subject: [PATCH] fix newlines --- helix-term/src/commands.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index d6e739585..81a5c38e4 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2721,6 +2721,7 @@ fn global_refactor(cx: &mut Context) { match &document_type { helix_view::document::DocumentType::File => return, helix_view::document::DocumentType::Refactor { matches, line_map } => { + let line_ending: LineEnding = cx.editor.config.load().default_line_ending.into(); let refactor_id = doc!(cx.editor).id(); let replace_text = doc!(cx.editor).text().clone(); let view = view!(cx.editor).clone(); @@ -2732,10 +2733,15 @@ fn global_refactor(cx: &mut Context) { if let Some(re_line) = line_map.get(&(key.clone(), *line)) { let mut replace = replace_text .get_line(*re_line) - .unwrap_or_else(|| "\n".into()) + .unwrap_or_else(|| "".into()) .to_string() .clone(); - replace = replace.strip_suffix('\n').unwrap_or(&replace).to_string(); + + replace = replace + .strip_suffix(line_ending.as_str()) + .unwrap_or(&replace) + .to_string(); + replace.push_str(line_ending.as_str()); if text != &replace { changes.push((*line, text.chars().count(), replace)); }