Skip to content

Commit

Permalink
move paste regex into paste_impl
Browse files Browse the repository at this point in the history
  • Loading branch information
kirawi committed Sep 10, 2021
1 parent d6b04a4 commit 043cd8d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3415,10 +3415,6 @@ enum Paste {
After,
}

// Only compiled once.
#[allow(clippy::trivial_regex)]
static PASTE_LINE_ENDING_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"\r\n|\r|\n").unwrap());

fn paste_impl(
values: &[String],
doc: &mut Document,
Expand All @@ -3437,6 +3433,9 @@ fn paste_impl(
.iter()
.any(|value| get_line_ending_of_str(value).is_some());

// Only compiled once.
#[allow(clippy::trivial_regex)]
static REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"\r\n|\r|\n").unwrap());
let mut values = values
.iter()
.map(|value| PASTE_LINE_ENDING_REGEX.replace_all(value, doc.line_ending.as_str()))
Expand Down

0 comments on commit 043cd8d

Please sign in to comment.