diff --git a/helix-core/src/conflict.rs b/helix-core/src/conflict.rs index eee736e5..d5462ff5 100644 --- a/helix-core/src/conflict.rs +++ b/helix-core/src/conflict.rs @@ -43,6 +43,9 @@ use imara_diff::{Algorithm, Diff, InternedInput}; use crate::Rope; +/// Sentinel value for [`ConflictRefineEntry::pair`] — skip word-diff rendering. +pub const NO_HIGHLIGHT_PAIR: usize = usize::MAX; + // ── Types ───────────────────────────────────────────────────────────────────── /// Pair of removed/added word-diff ranges for a conflict refine pair. @@ -55,6 +58,7 @@ pub struct ConflictRefineEntry { /// For a 3-section diff3 conflict: 0 = current↔base, 1 = base↔incoming, 2 = current↔incoming. /// For N-way jj conflicts the ordering prioritises each side vs base, /// then side–side comparisons; remaining base-involving pairs are excluded. + /// Set to [`NO_HIGHLIGHT_PAIR`] to disable word-diff rendering. pub pair: usize, /// Cached word-diff results for the current `pair`: /// `(removed_ranges, added_ranges)`. @@ -840,7 +844,7 @@ mod tests { assert_eq!(c.sections[2].kind, SectionKind::Side); assert_eq!(c.sections[3].kind, SectionKind::Base); assert_eq!(c.sections[4].kind, SectionKind::Side); - assert_eq!(c.num_refine_pairs(), 10); // C(5,2) + assert_eq!(c.num_refine_pairs(), 6); } // ── conflict_at ─────────────────────────────────────────────────────────── diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 40d4f37e..acd75665 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -6349,6 +6349,7 @@ fn conflict_accept_at_cursor(cx: &mut Context) { } fn conflict_cycle_diffs(cx: &mut Context) { + use helix_core::conflict::NO_HIGHLIGHT_PAIR; let (view, doc) = current!(cx.editor); let text = doc.text(); let cursor = doc.selection(view.id).primary().cursor(text.slice(..)); @@ -6367,7 +6368,13 @@ fn conflict_cycle_diffs(cx: &mut Context) { let mut cache = doc.conflict_cache.borrow_mut(); let entry = cache.entry(region.start).or_default(); - entry.pair = (entry.pair + 1) % region.num_refine_pairs(); + entry.pair = if entry.pair == NO_HIGHLIGHT_PAIR { + 0 + } else if entry.pair + 1 < region.num_refine_pairs() { + entry.pair + 1 + } else { + NO_HIGHLIGHT_PAIR + }; entry.diffs = None; } diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 3cfee49c..964ad0e7 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -14,7 +14,10 @@ use crate::{ }; use helix_core::{ - conflict::{conflict_marker_lines, conflict_pair_sections, refine_diff, ConflictRegion}, + conflict::{ + conflict_marker_lines, conflict_pair_sections, refine_diff, ConflictRegion, + NO_HIGHLIGHT_PAIR, + }, diagnostic::NumberOrString, graphemes::{next_grapheme_boundary, prev_grapheme_boundary}, movement::Direction, @@ -723,6 +726,9 @@ impl EditorView { } let entry = cache.entry(region.start).or_default(); + if entry.pair == NO_HIGHLIGHT_PAIR { + continue; + } let pair = entry.pair.min(region.num_refine_pairs().saturating_sub(1)); let Some((left, right)) = conflict_pair_sections(region, pair) else { continue;