Lint & fix typos

This commit is contained in:
Andras Schmelczer 2025-07-10 22:39:41 +01:00
parent 865d1f5073
commit 12c367db21
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
5 changed files with 50 additions and 40 deletions

View file

@ -1,12 +1,14 @@
//! # Reconcile: 3-way text merging with automatic conflict resolution
//!
//! A library for merging conflicting text edits without manual intervention.
//! Unlike traditional 3-way merge tools that produce conflict markers, this library
//! automatically resolves conflicts by applying both sets of changes where possible.
//! Unlike traditional 3-way merge tools that produce conflict markers, this
//! library automatically resolves conflicts by applying both sets of changes
//! where possible.
//!
//! Based on a combination of Myers' diff algorithm and Operational Transformation
//! principles, it's designed for scenarios where you have a common parent text
//! and two modified versions that need to be intelligently combined.
//! Based on a combination of Myers' diff algorithm and Operational
//! Transformation principles, it's designed for scenarios where you have a
//! common parent text and two modified versions that need to be intelligently
//! combined.
//!
//! **[Try the interactive demo](https://schmelczer.dev/reconcile)** to see it in action.
//!
@ -17,7 +19,7 @@
//!
//! // Start with original text
//! let parent = "Merging text is hard!";
//! // Two people edit simultaneously
//! // Two people edit simultaneously
//! let left = "Merging text is easy!"; // Changed "hard" to "easy"
//! let right = "With reconcile, merging documents is hard!"; // Added prefix and changed word
//!
@ -33,9 +35,12 @@
//!
//! ### Built-in tokenisers
//!
//! - **`BuiltinTokenizer::Word`** (recommended): Splits on word boundaries, preserving word integrity
//! - **`BuiltinTokenizer::Character`**: Character-level merging for fine-grained control
//! - **`BuiltinTokenizer::Line`**: Line-based merging, similar to traditional diff tools
//! - **`BuiltinTokenizer::Word`** (recommended): Splits on word boundaries,
//! preserving word integrity
//! - **`BuiltinTokenizer::Character`**: Character-level merging for
//! fine-grained control
//! - **`BuiltinTokenizer::Line`**: Line-based merging, similar to traditional
//! diff tools
//!
//! ```
//! use reconcile_text::{reconcile, BuiltinTokenizer};
@ -81,7 +86,8 @@
//! assert_eq!(result.apply().text(), "Hello beautiful world. This is a great test.");
//! ```
//!
//! > **Note**: Setting token joinability to `false` causes insertions to interleave
//! > **Note**: Setting token joinability to `false` causes insertions to
//! > interleave
//! > (LRLRLR) rather than group together (LLLRRR), which often produces more
//! > natural-looking merged text.
//!
@ -124,12 +130,16 @@
//!
//! ## Algorithm overview
//!
//! 1. **Diff computation**: Myers' algorithm calculates differences between parent↔left and parent↔right
//! 2. **Tokenisation**: Text is split into meaningful units (words, characters, etc.)
//! 3. **Diff optimisation**: Operations are reordered and consolidated for coherent changes
//! 1. **Diff computation**: Myers' algorithm calculates differences between
//! parent↔left and parent↔right
//! 2. **Tokenisation**: Text is split into meaningful units (words, characters,
//! etc.)
//! 3. **Diff optimisation**: Operations are reordered and consolidated for
//! coherent changes
//! 4. **Operational Transformation**: Edits are combined using OT principles
//!
//! For detailed algorithm explanation, see the [README](README.md#how-it-works).
//! For detailed algorithm explanation, see the
//! [README](README.md#how-it-works).
mod operation_transformation;
mod raw_operation;

View file

@ -5,7 +5,7 @@ use crate::{tokenizer::token::Token, utils::myers_diff::myers_diff};
/// Text editing operation containing the to-be-changed `Tokens`-s.
///
/// `RawOperations` can be joined together when the underlying tokens
/// allow for joining subseqeunt operations.
/// allow for joining subsequent operations.
#[derive(Debug, Clone, PartialEq)]
pub enum RawOperation<T>
where

View file

@ -3,8 +3,8 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;
// CursorPosition represents the position of an identifiable cursor in a text
// document based on its (UTF-8) character index.
/// `CursorPosition` represents the position of an identifiable cursor in a text
/// document based on its (UTF-8) character index.
#[allow(clippy::unsafe_derive_deserialize)]
#[cfg_attr(feature = "wasm", wasm_bindgen)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

View file

@ -189,7 +189,7 @@ where
// odd and when there is a reciprocal k line coming from the other
// direction.
if odd && (k - delta).abs() <= (d - 1) {
// TODO optimize this so we don't have to compare against n
// TODO optimise this so we don't have to compare against n
if vf[k] + vb[-(k - delta)] >= n {
// Return the snake
return Some((x0 + old_range.start, y0 + new_range.start));
@ -222,7 +222,7 @@ where
vb[k] = x;
if !odd && (k - delta).abs() <= d {
// TODO optimize this so we don't have to compare against n
// TODO optimise this so we don't have to compare against n
if vb[k] + vf[-(k - delta)] >= n {
// Return the snake
return Some((n - x + old_range.start, m - y + new_range.start));
@ -230,7 +230,7 @@ where
}
}
// TODO: Maybe there's an opportunity to optimize and bail early?
// TODO: Maybe there's an opportunity to optimise and bail early?
}
None