diff --git a/lib/src/conflicts.rs b/lib/src/conflicts.rs index 68455e5dc..357a71706 100644 --- a/lib/src/conflicts.rs +++ b/lib/src/conflicts.rs @@ -19,7 +19,7 @@ use std::iter::zip; use futures::{try_join, Stream, StreamExt, TryStreamExt}; use itertools::Itertools; -use regex::bytes::Regex; +use regex::bytes::{Regex, RegexBuilder}; use crate::backend::{BackendError, BackendResult, CommitId, FileId, SymlinkId, TreeId, TreeValue}; use crate::diff::{Diff, DiffHunk}; @@ -47,11 +47,10 @@ const CONFLICT_PLUS_LINE_CHAR: u8 = CONFLICT_PLUS_LINE[0]; // separators. This could be useful to make it possible to allow conflict // markers inside the text of the conflicts. static CONFLICT_MARKER_REGEX: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { - Regex::new( - r"(<{7}|>{7}|%{7}|\-{7}|\+{7})( .*)? -", - ) - .unwrap() + RegexBuilder::new(r"^(<{7}|>{7}|%{7}|\-{7}|\+{7})( .*)?$") + .multi_line(true) + .build() + .unwrap() }); fn write_diff_hunks(hunks: &[DiffHunk], file: &mut dyn Write) -> std::io::Result<()> { diff --git a/lib/tests/test_conflicts.rs b/lib/tests/test_conflicts.rs index 461935b02..8a7937331 100644 --- a/lib/tests/test_conflicts.rs +++ b/lib/tests/test_conflicts.rs @@ -611,7 +611,7 @@ fn test_parse_conflict_simple() { ) "### ); - // BUG: The conflict markers are too long and shouldn't parse (though we may + // The conflict markers are too long and shouldn't parse (though we may // decide to change this in the future) insta::assert_debug_snapshot!( parse_conflict(indoc! {b" @@ -629,25 +629,7 @@ fn test_parse_conflict_simple() { "}, 2 ), - @r###" - Some( - [ - Resolved( - "line 1\n", - ), - Conflicted( - [ - "line 2\nleft\nline 4\n", - "line 2\nline 3\nline 4\n", - "right\n", - ], - ), - Resolved( - "line 5\n", - ), - ], - ) - "### + @"None" ) }