Merge branch 'asch/better-api'
This commit is contained in:
commit
fb3c14b6ef
32 changed files with 6343 additions and 6250 deletions
41
.github/workflows/check.yml
vendored
41
.github/workflows/check.yml
vendored
|
|
@ -43,3 +43,44 @@ jobs:
|
|||
cargo test --features serde
|
||||
cargo test --features wasm
|
||||
wasm-pack test --node --features wasm
|
||||
|
||||
publish:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/main'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js environment
|
||||
uses: actions/setup-node@v4.2.0
|
||||
with:
|
||||
node-version: "22.x"
|
||||
check-latest: true
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Setup rust
|
||||
run: |
|
||||
cargo install wasm-pack
|
||||
|
||||
- name: Build wasm
|
||||
run: |
|
||||
wasm-pack build --target web --features wasm
|
||||
|
||||
- name: Publish to crates.io
|
||||
run: cargo publish --token ${{ secrets.CRATES_TOKEN }}
|
||||
continue-on-error: true
|
||||
|
||||
- name: Build reconcile-js
|
||||
run: |
|
||||
cd reconcile-js
|
||||
npm ci
|
||||
npm run build
|
||||
|
||||
- name: Publish reconcile-js to NPM
|
||||
run: |
|
||||
cd reconcile-js
|
||||
npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
continue-on-error: true
|
||||
|
|
|
|||
12
.github/workflows/gh-pages.yml
vendored
12
.github/workflows/gh-pages.yml
vendored
|
|
@ -15,7 +15,7 @@ permissions:
|
|||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
||||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
||||
concurrency:
|
||||
group: "pages"
|
||||
group: 'pages'
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
|
|
@ -31,13 +31,17 @@ jobs:
|
|||
run: |
|
||||
cargo install wasm-pack
|
||||
wasm-pack build --target web --features wasm
|
||||
cp -R pkg/reconcile.js examples/website/
|
||||
cp -R pkg/reconcile_bg.wasm examples/website/
|
||||
cd reconcile-js
|
||||
npm ci
|
||||
npm run build
|
||||
cd ../examples/website
|
||||
npm ci
|
||||
npm run build
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: examples/website
|
||||
path: examples/website/dist
|
||||
|
||||
deploy:
|
||||
environment:
|
||||
|
|
|
|||
|
|
@ -3,8 +3,5 @@
|
|||
"printWidth": 90,
|
||||
"tabWidth": 2,
|
||||
"singleQuote": true,
|
||||
"endOfLine": "lf",
|
||||
"importOrder": ["^[./]", ".*", ".scss$"],
|
||||
"importOrderSeparation": true,
|
||||
"importOrderSortSpecifiers": true
|
||||
}
|
||||
"endOfLine": "lf"
|
||||
}
|
||||
180
README.md
180
README.md
|
|
@ -3,148 +3,172 @@
|
|||
[](https://github.com/schmelczer/reconcile/actions/workflows/check.yml)
|
||||
[](https://github.com/schmelczer/reconcile/actions/workflows/gh-pages.yml)
|
||||
|
||||
> [`diff3`](https://www.gnu.org/software/diffutils/manual/html_node/Invoking-diff3.html) (or `git merge`) but with automatic conflict resolution.
|
||||
> Think [`diff3`](https://www.gnu.org/software/diffutils/manual/html_node/Invoking-diff3.html) or `git merge`, but with intelligent conflict resolution that just works.
|
||||
|
||||
Reconcile is a Rust and JavaScript (through WebAssembly) library for merging text without user intervention. It automatically resolves conflicts that would typically require user action in traditional 3-way merge tools.
|
||||
Reconcile is a Rust and JavaScript (via WebAssembly) library that merges conflicting text edits without requiring manual intervention. Where traditional 3-way merge tools would leave you with conflict markers to resolve by hand, Reconcile automatically weaves changes together using sophisticated algorithms inspired by Operational Transformation.
|
||||
|
||||
Try out the [interactive demo](https://schmelczer.dev/reconcile)!
|
||||
✨ **[Try the interactive demo](https://schmelczer.dev/reconcile)** to see it in action!
|
||||
|
||||
TODO: add links for crates and npm
|
||||
|
||||
## Features
|
||||
## What makes Reconcile special?
|
||||
|
||||
- **Conflict-free output** - No more git conflict markers in the result
|
||||
- **Cursor/selection position tracking** - Automatically updates cursor positions during merging
|
||||
- **Pluggable tokenizer** - Choose between word-level, character-level, or custom tokenization
|
||||
- **Full UTF-8 support** - Handles Unicode text correctly
|
||||
- **WebAssembly support** - Use from JavaScript/TypeScript applications
|
||||
- **🚫 No conflict markers** — Clean, merged output without Git's `<<<<<<<` noise
|
||||
- **📍 Cursor tracking** — Automatically repositions cursors and selections during merging
|
||||
- **🔧 Flexible tokenisation** — Word-level (default), character-level, or custom strategies
|
||||
- **🌍 Unicode-first** — Full UTF-8 support
|
||||
- **🕸️ Cross-platform** — Native Rust performance with WebAssembly for JavaScript
|
||||
|
||||
## Quick Start
|
||||
## Quick start
|
||||
|
||||
### Rust
|
||||
|
||||
Add to your `Cargo.toml`:
|
||||
Add `reconcile` to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
reconcile = "0.4"
|
||||
```
|
||||
|
||||
Then merge away:
|
||||
|
||||
```rust
|
||||
use reconcile::{reconcile, BuiltinTokenizer};
|
||||
|
||||
// Start with original text
|
||||
let parent = "Hello world";
|
||||
let left = "Hello beautiful world";
|
||||
let right = "Hi world";
|
||||
// Two people edit simultaneously
|
||||
let left = "Hello beautiful world"; // Added "beautiful"
|
||||
let right = "Hi world"; // Changed "Hello" to "Hi"
|
||||
|
||||
// Reconcile combines both changes intelligently
|
||||
let result = reconcile(parent, &left.into(), &right.into(), &*BuiltinTokenizer::Word);
|
||||
assert_eq!(result.apply().text(), "Hi beautiful world");
|
||||
```
|
||||
|
||||
### JavaScript/TypeScript
|
||||
|
||||
Install via npm:
|
||||
|
||||
```bash
|
||||
npm install reconcile
|
||||
```
|
||||
|
||||
```javascript
|
||||
import { init, reconcile } from "reconcile";
|
||||
Then use in your application:
|
||||
|
||||
// Initialize the WASM module (required before first use)
|
||||
```javascript
|
||||
import { init, reconcile } from 'reconcile';
|
||||
|
||||
// One-time setup: initialise the WASM module
|
||||
await init();
|
||||
|
||||
const parent = "Hello world";
|
||||
const left = "Hello beautiful world";
|
||||
const right = "Hi world";
|
||||
// Same example as above
|
||||
const parent = 'Hello world';
|
||||
const left = 'Hello beautiful world';
|
||||
const right = 'Hi world';
|
||||
|
||||
const result = reconcile(parent, left, right);
|
||||
console.log(result.text); // "Hi beautiful world"
|
||||
```
|
||||
|
||||
## API
|
||||
## Advanced usage
|
||||
|
||||
### Tokenizers
|
||||
### Edit provenance
|
||||
|
||||
Reconcile supports different tokenization strategies:
|
||||
|
||||
- **Word tokenizer** (`BuiltinTokenizer::Word`): Splits text into words (default, recommended for most use cases)
|
||||
- **Character tokenizer** (`BuiltinTokenizer::Character`): Splits text into individual characters (fine-grained merging)
|
||||
- **Custom tokenizer**: Implement your own tokenization logic
|
||||
|
||||
### Cursor Tracking
|
||||
|
||||
Reconcile can automatically update cursor and selection positions during merging:
|
||||
|
||||
```javascript
|
||||
const result = reconcile(
|
||||
"Hello world",
|
||||
{
|
||||
text: "Hello beautiful world",
|
||||
cursors: [{ id: 1, position: 6 }], // After "Hello "
|
||||
},
|
||||
{
|
||||
text: "Hi world",
|
||||
cursors: [{ id: 2, position: 0 }], // At beginning
|
||||
}
|
||||
);
|
||||
|
||||
// Result includes updated cursor positions
|
||||
console.log(result.cursors); // [{ id: 1, position: 3 }, { id: 2, position: 0 }]
|
||||
```
|
||||
|
||||
### History Tracking
|
||||
|
||||
Use `reconcileWithHistory` to get detailed information about the merge process:
|
||||
Track which changes came from where using `reconcileWithHistory`:
|
||||
|
||||
```javascript
|
||||
const result = reconcileWithHistory(parent, left, right);
|
||||
console.log(result.history); // Array of spans with their origins
|
||||
console.log(result.history); // Detailed breakdown of each text span's origin
|
||||
```
|
||||
|
||||
## Algorithm
|
||||
### Tokenisation strategies
|
||||
|
||||
The algorithm starts similarly to `diff3`. Its inputs are a **parent** document and two conflicting versions: `left` and `right` which have been created from the parent through any series of concurrent edits.
|
||||
Reconcile offers different ways to split text for merging:
|
||||
|
||||
1. **Diff calculation**: First, 2-way diffs of (parent & left) and (parent & right) are computed using Myers' algorithm
|
||||
2. **Tokenization**: The text is split into tokens (words, characters, etc.) for granular merging
|
||||
3. **Diff cleaning**: The tokens of the same diff are reordered and merged to end up to maximise patch sizes
|
||||
4. **Operation transformation (OT)**: The resulting edits are weaved together using operational transformation principles, ensuring no changes are lost
|
||||
- **Word tokeniser** (`BuiltinTokenizer::Word`) — Splits on word boundaries (recommended for prose)
|
||||
- **Character tokeniser** (`BuiltinTokenizer::Character`) — Individual characters (fine-grained control)
|
||||
- **Line tokeniser** (`BuiltinTokenizer::Line`) — Line-by-line (similar to `git merge`)
|
||||
- **Custom tokeniser** — Roll your own for specialised use cases
|
||||
|
||||
`EditedText` (at least in the Rust library) exposes an implementation of OT. The primary purpose of this library isn't to implement OT but to provide automated text merging, howver, OT happens to provide an easy way of merging the output of Myers' diff. The same result could be achieved through many CRDT implementations as well. However, the merging quality is only as good as the 2-way diffs are. For instance, `reconcile` doesn't support `move` semantics as these are decomposed into an `insert` and `delete` operation by Myers'.
|
||||
### Cursor tracking
|
||||
|
||||
## Motivation
|
||||
Ideal for collaborative editors — Reconcile tracks cursor positions through merges:
|
||||
|
||||
Sometimes documents get edited concurrently by multiple users (or the same user from multiple devices) resulting in divergent changes.
|
||||
```javascript
|
||||
const result = reconcile(
|
||||
'Hello world',
|
||||
{
|
||||
text: 'Hello beautiful world',
|
||||
cursors: [{ id: 1, position: 6 }], // After "Hello "
|
||||
},
|
||||
{
|
||||
text: 'Hi world',
|
||||
cursors: [{ id: 2, position: 0 }], // At the beginning
|
||||
}
|
||||
);
|
||||
|
||||
To allow for offline editing, we could use CRDTs or Operational Transformation (OT) to come to a consistent resolution of the competing version. However, this requires capturing all user actions: insertions, deletes, move, copies, and pastes. In some applications, this is trivial if the document can only be edited through an editor that's in our control. But this isn't always the case. Users enjoy composable systems that don't lock them in. For example, one of the unique selling points of Obsidian is to provide an editor experience over a folder of Markdown files leaving the user free to change their technology of choice on a whim.
|
||||
// Cursors are automatically repositioned in the merged text
|
||||
console.log(result.cursors); // [{ id: 1, position: 3 }, { id: 2, position: 0 }]
|
||||
```
|
||||
|
||||
This means that files can be edited out-of-channel and the only information a text synchronization system can know is the current content of each tracked file. This is described as Differential Synchronization [1]. This is the same problem as what Git and similar version control systems solve but in a manual way. Although the problem is similar, there's a relevant difference between syncing source code and personal notes: in the case of the former, a semantically incorrect conflict resolution can wreak havoc in a code base, or worse, introduce a correctness bug unnoticed. Text notes are different though, humans are well-equipped to finding the signal in a noisy environment and "bad merges" might result in a clumsy sentence but the reader will likely still understand the gist and can fix it if necessary.
|
||||
## How it works
|
||||
|
||||
> There are domains of human text which are less tolerant of mis-merges: for instance, two conflicting changes to a contract could result in a term getting negated in different ways from both sides, resulting in a double-negation, thus unknowingly changing the meaning.
|
||||
Reconcile builds upon the foundation of `diff3` but adds intelligent conflict resolution. Given a **parent** document and two modified versions (`left` and `right`), here's what happens:
|
||||
|
||||
1. **Diff computation** — Myers' algorithm calculates differences between (parent ↔ left) and (parent ↔ right)
|
||||
2. **Tokenisation** — Text splits into meaningful units (words, characters, etc.) for granular merging
|
||||
3. **Diff optimisation** — Operations are reordered and consolidated to maximise coherent changes
|
||||
4. **Operational Transformation** — Edits are woven together using OT principles, preserving all modifications
|
||||
|
||||
Whilst Reconcile's primary goal isn't implementing Operational Transformation, OT provides an elegant way to merge Myers' diff output. The same could be achieved with CRDTs, though the quality depends entirely on the underlying 2-way diffs. Note that `move` operations aren't supported, as Myers' algorithm decomposes them into separate `insert` and `delete` operations.
|
||||
|
||||
## Why Reconcile exists
|
||||
|
||||
Collaborative editing is everywhere — multiple users editing documents simultaneously, or the same person working across devices. This creates the inevitable challenge of conflicting changes.
|
||||
|
||||
Traditional solutions like CRDTs or Operational Transformation work brilliantly when you control the entire editing environment. They capture every keystroke, cursor movement, and operation. But real-world workflows are messier: users love tools that don't lock them in. Take Obsidian's approach with plain Markdown files — users can edit with any tool they fancy, from Vim to Word.
|
||||
|
||||
This creates what's known as **Differential Synchronisation** [¹]: you only know the final state of each document, not how it got there. It's the same challenge Git tackles, but Git expects humans to resolve conflicts manually.
|
||||
|
||||
Here's the key insight: whilst incorrect merges in source code can introduce devastating bugs, human text is more forgiving. People excel at extracting meaning from imperfect text — a slightly clumsy sentence is preferable to conflict markers interrupting the flow.
|
||||
|
||||
> **Caveat**: Some text domains are less tolerant of imperfect merges. Legal contracts, for instance, could have unintended meaning changes from double-negations created by conflicting edits.
|
||||
|
||||
## Development
|
||||
|
||||
### Prerequisites
|
||||
|
||||
#### Install Node.js
|
||||
#### Node.js setup
|
||||
|
||||
- Install [nvm](https://github.com/nvm-sh/nvm): `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash`
|
||||
- `nvm install 22`
|
||||
- `nvm use 22`
|
||||
- Optionally set the system-wide default: `nvm alias default 22`
|
||||
1. Install [nvm](https://github.com/nvm-sh/nvm):
|
||||
```bash
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
||||
```
|
||||
2. Install and use Node 22:
|
||||
```bash
|
||||
nvm install 22 && nvm use 22
|
||||
```
|
||||
3. Optionally set as default: `nvm alias default 22`
|
||||
|
||||
#### Set up Rust
|
||||
#### Rust toolchain
|
||||
|
||||
- Install [`rustup`](https://rustup.rs): `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
|
||||
- `cargo install wasm-pack cargo-insta cargo-edit`
|
||||
1. Install [rustup](https://rustup.rs):
|
||||
```bash
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
```
|
||||
2. Install additional tools:
|
||||
```bash
|
||||
cargo install wasm-pack cargo-insta cargo-edit
|
||||
```
|
||||
|
||||
### Scripts
|
||||
### Development scripts
|
||||
|
||||
- **Running tests**: `scripts/test.sh`
|
||||
- **Formatting**: `scripts/lint.sh`
|
||||
- **Building website**: `scripts/dev-website.sh`
|
||||
- **Publishing new version**: `scripts/bump-version.sh patch`
|
||||
- **Run tests**: `scripts/test.sh`
|
||||
- **Lint and format**: `scripts/lint.sh`
|
||||
- **Build demo website**: `scripts/dev-website.sh`
|
||||
- **Publish new version**: `scripts/bump-version.sh patch`
|
||||
|
||||
TODO: license
|
||||
|
||||
[1]: https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/35605.pdf
|
||||
[¹]: https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/35605.pdf
|
||||
|
|
|
|||
|
|
@ -8,18 +8,18 @@
|
|||
/>
|
||||
<meta
|
||||
name="description"
|
||||
content="Easily merge three versions of a text document with this 3-way text merge tool."
|
||||
content="3-way text merging that automatically resolves conflicts. No more Git conflict markers — just clean, merged results."
|
||||
/>
|
||||
<meta property="og:title" content="3-Way Text Merge" />
|
||||
<meta
|
||||
property="og:description"
|
||||
content="Easily merge three versions of a text document with this 3-way text merge tool."
|
||||
content="3-way text merging that automatically resolves conflicts. No more Git conflict markers — just clean, merged results."
|
||||
/>
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="https://github.com/schmelczer/reconcile" />
|
||||
<meta property="og:url" content="https://schmelczer.dev/reconcile" />
|
||||
<meta property="og:image" content="/favicon.ico" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
<title>3-Way Text Merge</title>
|
||||
<title>Reconcile: conflict-free text merging</title>
|
||||
<link inline inline-asset="index.css" inline-asset-delete />
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -28,49 +28,58 @@
|
|||
<div class="scroll-container">
|
||||
<div class="page-wrapper">
|
||||
<header>
|
||||
<h1>Reconcile: automated 3-way text merge</h1>
|
||||
<h1>Reconcile: conflict-free 3-way text merging</h1>
|
||||
<p>
|
||||
The
|
||||
<a
|
||||
href="https://github.com/schmelczer/reconcile"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>reconcile</a
|
||||
>
|
||||
library solves a fundamental challenge in collaborative editing: what happens
|
||||
when multiple users edit the same text simultaneously but we can only capture
|
||||
the end result, not the intermediary edits? Essentially, it's
|
||||
Think
|
||||
<a
|
||||
href="https://www.gnu.org/software/diffutils/manual/html_node/Invoking-diff3.html"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>diff3</a
|
||||
>
|
||||
(or <code>git merge</code>) but with automatic conflict resolution.
|
||||
</p>
|
||||
<p>
|
||||
The
|
||||
<code>reconcile(parent: str, left: str, right: str) -> str</code>
|
||||
takes conflicting concurrent edits and intelligently merges them into a
|
||||
unified result. Beyond basic conflict resolution, it offers sophisticated
|
||||
merging heuristics, flexible tokenization options, and cursor position
|
||||
tracking.
|
||||
</p>
|
||||
<p>
|
||||
The algorithm begins with your chosen tokenizer, then applies Myers' diff
|
||||
algorithm to compare the original text with both conflicting versions. These
|
||||
diffs undergo transformation to preserve meaningful change sequences, before a
|
||||
final merge strategy—inspired by Operational Transformation reconciles all
|
||||
conflicting modifications without losing any edits.
|
||||
</p>
|
||||
<p>
|
||||
For more details, see the
|
||||
<a href="https://github.com/schmelczer/reconcile" target="_blank">README</a>.
|
||||
or <code>git merge</code>, but with intelligent conflict resolution that
|
||||
requires no user intervention. The
|
||||
<a
|
||||
href="https://github.com/schmelczer/reconcile"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>Reconcile</a
|
||||
>
|
||||
library tackles a fundamental challenge in collaborative editing: what happens
|
||||
when multiple users edit the same text simultaneously, but the conflict
|
||||
resolver only has access to the final results, not the intermediate steps?
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Use the tokenization options below to experiment with different strategies.
|
||||
The library supports user-defined tokenizers as well.
|
||||
Where traditional merge tools leave you with conflict markers to resolve
|
||||
manually, Reconcile automatically weaves changes together. The
|
||||
<code>reconcile(parent, left, right)</code> function takes conflicting edits
|
||||
and produces clean, unified results using an algorithm inspired by Operational
|
||||
Transformation. No more <code><<<<<<<</code> markers
|
||||
cluttering your text.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The process starts with your chosen tokenisation strategy, then applies Myers'
|
||||
diff algorithm to compare the original with both modified versions. These
|
||||
diffs are optimised and transformed to preserve meaningful changes, before a
|
||||
final merge strategy combines all modifications without losing any edits.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Ready to dive deeper? Check out the
|
||||
<a
|
||||
href="https://github.com/schmelczer/reconcile"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>documentation</a
|
||||
>
|
||||
or try editing the text boxes below to see Reconcile in action.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Use the tokenisation options below to experiment with different approaches —
|
||||
the library also supports custom tokenisers.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
|
|
@ -87,7 +96,9 @@
|
|||
<span class="radio-custom" aria-hidden="true"></span>
|
||||
<div class="radio-content">
|
||||
<span class="radio-label">Character</span>
|
||||
<span class="radio-description">Split by individual characters</span>
|
||||
<span class="radio-description"
|
||||
>Fine-grained character-level merging</span
|
||||
>
|
||||
</div>
|
||||
</label>
|
||||
<label class="radio-option">
|
||||
|
|
@ -101,7 +112,7 @@
|
|||
<span class="radio-custom" aria-hidden="true"></span>
|
||||
<div class="radio-content">
|
||||
<span class="radio-label">Word</span>
|
||||
<span class="radio-description">Split by words (default)</span>
|
||||
<span class="radio-description">Retain full words (default)</span>
|
||||
</div>
|
||||
</label>
|
||||
<label class="radio-option">
|
||||
|
|
@ -110,7 +121,7 @@
|
|||
<div class="radio-content">
|
||||
<span class="radio-label">Line</span>
|
||||
<span class="radio-description"
|
||||
>Split by lines similarly to <code>git merge</code></span
|
||||
>Line-by-line like <code>git merge</code></span
|
||||
>
|
||||
</div>
|
||||
</label>
|
||||
|
|
@ -120,7 +131,7 @@
|
|||
<div class="text-area-card diamond-parent">
|
||||
<label
|
||||
for="original"
|
||||
title="The text document's content before any concurrent edits occurred."
|
||||
title="The original text before any concurrent edits were made."
|
||||
>Original</label
|
||||
>
|
||||
<textarea id="original" name="original"></textarea>
|
||||
|
|
@ -129,9 +140,9 @@
|
|||
<div class="text-area-card diamond-left">
|
||||
<label
|
||||
for="left"
|
||||
title="Colour-coded tokens mark the origin of each token in the result. This text box is marked with the colour green."
|
||||
title="First user's edits — changes from this box appear in green in the result."
|
||||
>
|
||||
First concurrent edit
|
||||
First user's edits
|
||||
<div class="box Left"></div>
|
||||
</label>
|
||||
<textarea id="left" name="left"></textarea>
|
||||
|
|
@ -140,9 +151,9 @@
|
|||
<div class="text-area-card diamond-right">
|
||||
<label
|
||||
for="right"
|
||||
title="Colour-coded tokens mark the origin of each token in the result. This text box is marked with the colour blue."
|
||||
title="Second user's edits — changes from this box appear in blue in the result."
|
||||
>
|
||||
Second concurrent edit
|
||||
Second user's edits
|
||||
<div class="box Right"></div>
|
||||
</label>
|
||||
<textarea id="right" name="right"></textarea>
|
||||
|
|
@ -151,9 +162,9 @@
|
|||
<div class="text-area-card diamond-result">
|
||||
<label
|
||||
for="merged"
|
||||
title="Read-only. Change the above text boxes to change the content of this box."
|
||||
title="The automatically merged result — edit the boxes above to see changes in real-time."
|
||||
>
|
||||
Deconflicted result
|
||||
Merged result
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
|
|
|
|||
|
|
@ -1,38 +1,32 @@
|
|||
{
|
||||
"name": "portfolio",
|
||||
"description": "An easily configurable timeline of projects.",
|
||||
"name": "reconcile-example-website",
|
||||
"description": "",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "webpack serve --open --mode development",
|
||||
"format": "prettier --write \"src/**/*.(ts|scss|json|html)\"",
|
||||
"format": "prettier --write \"./**/*.(ts|scss|json|html)\"",
|
||||
"build": "webpack --mode production"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/schmelczer/schmelczer.github.io.git"
|
||||
"url": "git+https://github.com/schmelczer/reconcile.git"
|
||||
},
|
||||
"keywords": [
|
||||
"CV",
|
||||
"curriculum",
|
||||
"vitae",
|
||||
"portfolio",
|
||||
"resumé"
|
||||
],
|
||||
"keywords": [],
|
||||
"author": "Andras Schmelczer",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"bugs": {
|
||||
"url": "https://github.com/schmelczer/schmelczer.github.io/issues"
|
||||
"url": "https://github.com/schmelczer/reconcile/issues"
|
||||
},
|
||||
"browserslist": [
|
||||
"defaults"
|
||||
],
|
||||
"homepage": "https://github.com/schmelczer/schmelczer.github.io#readme",
|
||||
"homepage": "https://github.com/schmelczer/reconcile#readme",
|
||||
"devDependencies": {
|
||||
"reconcile": "file:../../reconcile-js",
|
||||
"css-loader": "^7.1.2",
|
||||
"html-webpack-plugin": "^5.6.3",
|
||||
"inline-source-webpack-plugin": "^3.0.1",
|
||||
"mini-css-extract-plugin": "^2.9.2",
|
||||
"inline-source-webpack-plugin": "^3.0.1",
|
||||
"prettier": "^3.6.2",
|
||||
"resolve-url-loader": "^5.0.0",
|
||||
"sass": "^1.89.2",
|
||||
|
|
|
|||
|
|
@ -56,6 +56,16 @@ p * {
|
|||
user-select: text;
|
||||
}
|
||||
|
||||
code {
|
||||
background: #61769a;
|
||||
color: #e2e8f0;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
|
||||
font-size: 0.875em;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
header > p {
|
||||
color: #5a6272;
|
||||
font-size: 1.1rem;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,17 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"strict": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "bundler",
|
||||
"declaration": true,
|
||||
"declarationDir": "./dist/types",
|
||||
"outDir": "./dist",
|
||||
"rootDir": ".",
|
||||
"skipLibCheck": true,
|
||||
"inlineSourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"./dist"
|
||||
]
|
||||
}
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"strict": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "bundler",
|
||||
"declaration": true,
|
||||
"declarationDir": "./dist/types",
|
||||
"outDir": "./dist",
|
||||
"rootDir": ".",
|
||||
"skipLibCheck": true,
|
||||
"inlineSourceMap": true
|
||||
},
|
||||
"exclude": ["./dist"]
|
||||
}
|
||||
|
|
|
|||
11513
reconcile-js/package-lock.json
generated
11513
reconcile-js/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,24 +1,26 @@
|
|||
{
|
||||
"name": "reconcile",
|
||||
"version": "0.4.0",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/types/index.d.ts",
|
||||
"files": [
|
||||
"dist/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "webpack --mode production",
|
||||
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^30.0.0",
|
||||
"jest": "^30.0.4",
|
||||
"reconcile": "file:../pkg",
|
||||
"ts-jest": "^29.4.0",
|
||||
"ts-loader": "^9.5.2",
|
||||
"tslib": "2.8.1",
|
||||
"typescript": "5.8.3",
|
||||
"webpack": "^5.99.9",
|
||||
"webpack-cli": "^6.0.1"
|
||||
}
|
||||
}
|
||||
"name": "reconcile",
|
||||
"version": "0.4.0",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/types/index.d.ts",
|
||||
"files": [
|
||||
"dist/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "webpack --mode production",
|
||||
"format": "prettier --write \"./**/*.(ts|scss|json|html)\"",
|
||||
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^30.0.0",
|
||||
"jest": "^30.0.4",
|
||||
"reconcile": "file:../pkg",
|
||||
"ts-jest": "^29.4.0",
|
||||
"ts-loader": "^9.5.2",
|
||||
"tslib": "2.8.1",
|
||||
"typescript": "5.8.3",
|
||||
"webpack": "^5.99.9",
|
||||
"webpack-cli": "^6.0.1",
|
||||
"prettier": "^3.6.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,70 +1,66 @@
|
|||
import { init, reconcile, reconcileWithHistory } from "./index";
|
||||
import * as fs from "fs";
|
||||
import { init, reconcile, reconcileWithHistory } from './index';
|
||||
import * as fs from 'fs';
|
||||
|
||||
describe("reconcile", () => {
|
||||
it("tries calling functions without init", () => {
|
||||
expect(() => reconcile("Hello", "Hello world", "Hi world")).toThrow(
|
||||
/call init()/
|
||||
);
|
||||
describe('reconcile', () => {
|
||||
it('tries calling functions without init', () => {
|
||||
expect(() => reconcile('Hello', 'Hello world', 'Hi world')).toThrow(/call init()/);
|
||||
|
||||
expect(() =>
|
||||
reconcileWithHistory("Hello", "Hello world", "Hi world")
|
||||
).toThrow(/call init()/);
|
||||
});
|
||||
expect(() => reconcileWithHistory('Hello', 'Hello world', 'Hi world')).toThrow(
|
||||
/call init()/
|
||||
);
|
||||
});
|
||||
|
||||
it("call reconcile without cursors", async () => {
|
||||
await initWasm();
|
||||
it('call reconcile without cursors', async () => {
|
||||
await initWasm();
|
||||
|
||||
expect(reconcile("Hello", "Hello world", "Hi world").text).toEqual(
|
||||
"Hi world"
|
||||
);
|
||||
});
|
||||
expect(reconcile('Hello', 'Hello world', 'Hi world').text).toEqual('Hi world');
|
||||
});
|
||||
|
||||
it("call reconcile with cursors", async () => {
|
||||
await initWasm();
|
||||
it('call reconcile with cursors', async () => {
|
||||
await initWasm();
|
||||
|
||||
const result = reconcile(
|
||||
"Hello",
|
||||
{
|
||||
text: "Hello world",
|
||||
cursors: [
|
||||
{
|
||||
id: 3,
|
||||
position: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "Hi world",
|
||||
cursors: [
|
||||
{
|
||||
id: 4,
|
||||
position: 0,
|
||||
},
|
||||
{ id: 5, position: 3 },
|
||||
],
|
||||
}
|
||||
);
|
||||
const result = reconcile(
|
||||
'Hello',
|
||||
{
|
||||
text: 'Hello world',
|
||||
cursors: [
|
||||
{
|
||||
id: 3,
|
||||
position: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Hi world',
|
||||
cursors: [
|
||||
{
|
||||
id: 4,
|
||||
position: 0,
|
||||
},
|
||||
{ id: 5, position: 3 },
|
||||
],
|
||||
}
|
||||
);
|
||||
|
||||
expect(result.text).toEqual("Hi world");
|
||||
expect(result.cursors).toEqual([
|
||||
{ id: 3, position: 0 },
|
||||
{ id: 4, position: 0 },
|
||||
{ id: 5, position: 3 },
|
||||
]);
|
||||
});
|
||||
expect(result.text).toEqual('Hi world');
|
||||
expect(result.cursors).toEqual([
|
||||
{ id: 3, position: 0 },
|
||||
{ id: 4, position: 0 },
|
||||
{ id: 5, position: 3 },
|
||||
]);
|
||||
});
|
||||
|
||||
it("call reconcileWithHistory", async () => {
|
||||
await initWasm();
|
||||
it('call reconcileWithHistory', async () => {
|
||||
await initWasm();
|
||||
|
||||
const result = reconcileWithHistory("Hello", "Hello world", "Hi world");
|
||||
const result = reconcileWithHistory('Hello', 'Hello world', 'Hi world');
|
||||
|
||||
expect(result.text).toEqual("Hi world");
|
||||
expect(result.history.length).toBeGreaterThan(0);
|
||||
});
|
||||
expect(result.text).toEqual('Hi world');
|
||||
expect(result.history.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
async function initWasm() {
|
||||
const wasmBin = fs.readFileSync("../pkg/reconcile_bg.wasm");
|
||||
await init({ module_or_path: wasmBin });
|
||||
const wasmBin = fs.readFileSync('../pkg/reconcile_bg.wasm');
|
||||
await init({ module_or_path: wasmBin });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,54 +1,54 @@
|
|||
import wasmInit, {
|
||||
CursorPosition as wasmCursorPosition,
|
||||
reconcile as wasmReconcile,
|
||||
TextWithCursors as wasmTextWithCursors,
|
||||
SpanWithHistory as wasmSpanWithHistory,
|
||||
BuiltinTokenizer,
|
||||
reconcileWithHistory as wasmReconcileWithHistory,
|
||||
History,
|
||||
InitInput,
|
||||
} from "reconcile";
|
||||
CursorPosition as wasmCursorPosition,
|
||||
reconcile as wasmReconcile,
|
||||
TextWithCursors as wasmTextWithCursors,
|
||||
SpanWithHistory as wasmSpanWithHistory,
|
||||
BuiltinTokenizer,
|
||||
reconcileWithHistory as wasmReconcileWithHistory,
|
||||
History,
|
||||
InitInput,
|
||||
} from 'reconcile';
|
||||
|
||||
export interface TextWithCursors {
|
||||
/** The document's entire content */
|
||||
text: string;
|
||||
/** List of cursor positions, can be null or undefined if there are no cursors */
|
||||
cursors: null | undefined | CursorPosition[];
|
||||
/** The document's entire content */
|
||||
text: string;
|
||||
/** List of cursor positions, can be null or undefined if there are no cursors */
|
||||
cursors: null | undefined | CursorPosition[];
|
||||
}
|
||||
|
||||
export interface CursorPosition {
|
||||
/** Unique identifier for the cursor */
|
||||
id: number;
|
||||
/** Character position in the text, 0-based */
|
||||
position: number;
|
||||
/** Unique identifier for the cursor */
|
||||
id: number;
|
||||
/** Character position in the text, 0-based */
|
||||
position: number;
|
||||
}
|
||||
|
||||
export interface TextWithCursorsAndHistory {
|
||||
/** The document's entire content */
|
||||
text: string;
|
||||
/** List of cursor positions, can be null or undefined if there are no cursors */
|
||||
cursors: null | undefined | CursorPosition[];
|
||||
/** List of operations leading to `text` from the 3 ancestors */
|
||||
history: SpanWithHistory[];
|
||||
/** The document's entire content */
|
||||
text: string;
|
||||
/** List of cursor positions, can be null or undefined if there are no cursors */
|
||||
cursors: null | undefined | CursorPosition[];
|
||||
/** List of operations leading to `text` from the 3 ancestors */
|
||||
history: SpanWithHistory[];
|
||||
}
|
||||
|
||||
export interface SpanWithHistory {
|
||||
/** Span of text associated with the historical opearion */
|
||||
text: string;
|
||||
/** Origin of the `text` span */
|
||||
history: History;
|
||||
/** Span of text associated with the historical opearion */
|
||||
text: string;
|
||||
/** Origin of the `text` span */
|
||||
history: History;
|
||||
}
|
||||
|
||||
export type Tokenizer = "Line" | "Word" | "Character";
|
||||
const TOKENIZERS = ["Line", "Word", "Character"];
|
||||
export type Tokenizer = 'Line' | 'Word' | 'Character';
|
||||
const TOKENIZERS = ['Line', 'Word', 'Character'];
|
||||
|
||||
let isInitialised = false;
|
||||
|
||||
const UNINITIALISED_MODULE_ERROR =
|
||||
"Reconcile module has not been initialized. Please call init() before using any other functions.";
|
||||
'Reconcile module has not been initialized. Please call init() before using any other functions.';
|
||||
|
||||
const UNSUPPORTED_TOKENIZER_ERROR = `Unsupported tokenizer. Only ${TOKENIZERS.join(
|
||||
", "
|
||||
', '
|
||||
)} are supported.`;
|
||||
|
||||
/**
|
||||
|
|
@ -61,13 +61,13 @@ const UNSUPPORTED_TOKENIZER_ERROR = `Unsupported tokenizer. Only ${TOKENIZERS.jo
|
|||
* @returns Promise that resolves when initialization is complete
|
||||
*/
|
||||
export async function init(content?: InitInput) {
|
||||
if (isInitialised) {
|
||||
return;
|
||||
}
|
||||
if (isInitialised) {
|
||||
return;
|
||||
}
|
||||
|
||||
await wasmInit(content);
|
||||
await wasmInit(content);
|
||||
|
||||
isInitialised = true;
|
||||
isInitialised = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -80,31 +80,31 @@ export async function init(content?: InitInput) {
|
|||
* @returns The reconciled text with merged cursor positions
|
||||
*/
|
||||
export function reconcile(
|
||||
original: string,
|
||||
left: string | TextWithCursors,
|
||||
right: string | TextWithCursors,
|
||||
tokenizer: BuiltinTokenizer = "Word"
|
||||
original: string,
|
||||
left: string | TextWithCursors,
|
||||
right: string | TextWithCursors,
|
||||
tokenizer: BuiltinTokenizer = 'Word'
|
||||
): TextWithCursors {
|
||||
if (!isInitialised) {
|
||||
throw new Error(UNINITIALISED_MODULE_ERROR);
|
||||
}
|
||||
if (!isInitialised) {
|
||||
throw new Error(UNINITIALISED_MODULE_ERROR);
|
||||
}
|
||||
|
||||
if (!TOKENIZERS.includes(tokenizer)) {
|
||||
throw new Error(UNSUPPORTED_TOKENIZER_ERROR);
|
||||
}
|
||||
if (!TOKENIZERS.includes(tokenizer)) {
|
||||
throw new Error(UNSUPPORTED_TOKENIZER_ERROR);
|
||||
}
|
||||
|
||||
const leftCursor = toWasmTextWithCursors(left);
|
||||
const rightCursor = toWasmTextWithCursors(right);
|
||||
const leftCursor = toWasmTextWithCursors(left);
|
||||
const rightCursor = toWasmTextWithCursors(right);
|
||||
|
||||
const result = wasmReconcile(original, leftCursor, rightCursor, tokenizer);
|
||||
const result = wasmReconcile(original, leftCursor, rightCursor, tokenizer);
|
||||
|
||||
leftCursor.free();
|
||||
rightCursor.free();
|
||||
leftCursor.free();
|
||||
rightCursor.free();
|
||||
|
||||
const jsResult = toTextWithCursors(result);
|
||||
result.free();
|
||||
const jsResult = toTextWithCursors(result);
|
||||
result.free();
|
||||
|
||||
return jsResult;
|
||||
return jsResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -119,83 +119,66 @@ export function reconcile(
|
|||
* @returns The reconciled text with cursor positions and history of changes
|
||||
*/
|
||||
export function reconcileWithHistory(
|
||||
original: string,
|
||||
left: string | TextWithCursors,
|
||||
right: string | TextWithCursors,
|
||||
tokenizer: BuiltinTokenizer = "Word"
|
||||
original: string,
|
||||
left: string | TextWithCursors,
|
||||
right: string | TextWithCursors,
|
||||
tokenizer: BuiltinTokenizer = 'Word'
|
||||
): TextWithCursorsAndHistory {
|
||||
if (!isInitialised) {
|
||||
throw new Error(UNINITIALISED_MODULE_ERROR);
|
||||
}
|
||||
if (!isInitialised) {
|
||||
throw new Error(UNINITIALISED_MODULE_ERROR);
|
||||
}
|
||||
|
||||
if (!TOKENIZERS.includes(tokenizer)) {
|
||||
throw new Error(UNSUPPORTED_TOKENIZER_ERROR);
|
||||
}
|
||||
if (!TOKENIZERS.includes(tokenizer)) {
|
||||
throw new Error(UNSUPPORTED_TOKENIZER_ERROR);
|
||||
}
|
||||
|
||||
const leftCursor = toWasmTextWithCursors(left);
|
||||
const rightCursor = toWasmTextWithCursors(right);
|
||||
const leftCursor = toWasmTextWithCursors(left);
|
||||
const rightCursor = toWasmTextWithCursors(right);
|
||||
|
||||
const result = wasmReconcileWithHistory(
|
||||
original,
|
||||
leftCursor,
|
||||
rightCursor,
|
||||
tokenizer
|
||||
);
|
||||
const result = wasmReconcileWithHistory(original, leftCursor, rightCursor, tokenizer);
|
||||
|
||||
leftCursor.free();
|
||||
rightCursor.free();
|
||||
leftCursor.free();
|
||||
rightCursor.free();
|
||||
|
||||
const jsResult = toTextWithCursors(result);
|
||||
const history = result.history().map(toSpanWithHistory);
|
||||
result.free();
|
||||
const jsResult = toTextWithCursors(result);
|
||||
const history = result.history().map(toSpanWithHistory);
|
||||
result.free();
|
||||
|
||||
return {
|
||||
...jsResult,
|
||||
history,
|
||||
};
|
||||
return {
|
||||
...jsResult,
|
||||
history,
|
||||
};
|
||||
}
|
||||
|
||||
function toWasmTextWithCursors(
|
||||
text: string | TextWithCursors
|
||||
): wasmTextWithCursors {
|
||||
const isInputString = typeof text == "string";
|
||||
const leftText = isInputString ? text : text.text;
|
||||
const leftCursors = isInputString ? [] : text.cursors ?? [];
|
||||
function toWasmTextWithCursors(text: string | TextWithCursors): wasmTextWithCursors {
|
||||
const isInputString = typeof text == 'string';
|
||||
const leftText = isInputString ? text : text.text;
|
||||
const leftCursors = isInputString ? [] : (text.cursors ?? []);
|
||||
|
||||
return new wasmTextWithCursors(
|
||||
leftText,
|
||||
leftCursors.map(toWasmCursorPosition)
|
||||
);
|
||||
return new wasmTextWithCursors(leftText, leftCursors.map(toWasmCursorPosition));
|
||||
}
|
||||
|
||||
function toWasmCursorPosition({
|
||||
id,
|
||||
position,
|
||||
}: CursorPosition): wasmCursorPosition {
|
||||
return new wasmCursorPosition(id, position);
|
||||
function toWasmCursorPosition({ id, position }: CursorPosition): wasmCursorPosition {
|
||||
return new wasmCursorPosition(id, position);
|
||||
}
|
||||
|
||||
function toTextWithCursors(
|
||||
textWithCursor: wasmTextWithCursors
|
||||
): TextWithCursors {
|
||||
return {
|
||||
text: textWithCursor.text(),
|
||||
cursors: textWithCursor.cursors().map(toCursorPosition),
|
||||
};
|
||||
function toTextWithCursors(textWithCursor: wasmTextWithCursors): TextWithCursors {
|
||||
return {
|
||||
text: textWithCursor.text(),
|
||||
cursors: textWithCursor.cursors().map(toCursorPosition),
|
||||
};
|
||||
}
|
||||
|
||||
function toCursorPosition(cursor: wasmCursorPosition): CursorPosition {
|
||||
return {
|
||||
id: cursor.id(),
|
||||
position: cursor.characterIndex(),
|
||||
};
|
||||
return {
|
||||
id: cursor.id(),
|
||||
position: cursor.characterIndex(),
|
||||
};
|
||||
}
|
||||
|
||||
function toSpanWithHistory(
|
||||
textWithHistory: wasmSpanWithHistory
|
||||
): SpanWithHistory {
|
||||
return {
|
||||
text: textWithHistory.text(),
|
||||
history: textWithHistory.history(),
|
||||
};
|
||||
function toSpanWithHistory(textWithHistory: wasmSpanWithHistory): SpanWithHistory {
|
||||
return {
|
||||
text: textWithHistory.text(),
|
||||
history: textWithHistory.history(),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,17 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"strict": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "bundler",
|
||||
"declaration": true,
|
||||
"declarationDir": "./dist/types",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"skipLibCheck": true,
|
||||
"inlineSourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"./dist"
|
||||
]
|
||||
}
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"strict": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "bundler",
|
||||
"declaration": true,
|
||||
"declarationDir": "./dist/types",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"skipLibCheck": true,
|
||||
"inlineSourceMap": true
|
||||
},
|
||||
"exclude": ["./dist"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,4 +5,10 @@ set -e
|
|||
cargo clippy --all-targets --all-features --fix --allow-dirty --allow-staged
|
||||
cargo fmt --all
|
||||
|
||||
echo "Success!"
|
||||
cd reconcile-js
|
||||
npm run format
|
||||
|
||||
cd ../examples/website
|
||||
npm run format
|
||||
|
||||
echo "Success!"
|
||||
|
|
|
|||
88
src/lib.rs
88
src/lib.rs
|
|
@ -1,80 +1,86 @@
|
|||
//! # Reconcile
|
||||
//! # Reconcile: conflict-free 3-way text merging
|
||||
//!
|
||||
//! [`diff3`](https://www.gnu.org/software/diffutils/manual/html_node/Invoking-diff3.html) (or `git merge`)
|
||||
//! but with automatic conflict resolution.
|
||||
//! Think [`diff3`](https://www.gnu.org/software/diffutils/manual/html_node/Invoking-diff3.html) or `git merge`,
|
||||
//! but with intelligent conflict resolution.
|
||||
//!
|
||||
//! Reconcile is a Rust and JavaScript (through WebAssembly) library for merging
|
||||
//! text without user intervention. It automatically resolves conflicts that
|
||||
//! would typically require user action in traditional 3-way merge tools.
|
||||
//! Reconcile is a Rust and JavaScript (via WebAssembly) library that merges
|
||||
//! conflicting text edits without requiring manual intervention. Where
|
||||
//! traditional 3-way merge tools would leave you with conflict markers to
|
||||
//! resolve by hand, Reconcile automatically weaves changes together using
|
||||
//! sophisticated algorithms inspired by Operational Transformation.
|
||||
//!
|
||||
//! Try out the [interactive demo](https://schmelczer.dev/reconcile)!
|
||||
//! ✨ **[Try the interactive demo](https://schmelczer.dev/reconcile)** to see it in action!
|
||||
//!
|
||||
//! ```
|
||||
//! use reconcile::{reconcile, BuiltinTokenizer};
|
||||
//!
|
||||
//! // Start with original text
|
||||
//! let parent = "Merging text is hard!";
|
||||
//! let left = "Merging text is easy!";
|
||||
//! let right = "With reconcile, merging documents is hard!";
|
||||
//! // 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
|
||||
//!
|
||||
//! let deconflicted = reconcile(parent, &left.into(), &right.into(), &*BuiltinTokenizer::Word);
|
||||
//! assert_eq!(deconflicted.apply().text(), "With reconcile, merging documents is easy!");
|
||||
//! // Reconcile combines both changes intelligently
|
||||
//! let result = reconcile(parent, &left.into(), &right.into(), &*BuiltinTokenizer::Word);
|
||||
//! assert_eq!(result.apply().text(), "With reconcile, merging documents is easy!");
|
||||
//! ```
|
||||
//! > You can also try out an interactive demo at [schmelczer.dev/reconcile](https://schmelczer.dev/reconcile).
|
||||
//!
|
||||
//! ## Tokenizing
|
||||
//! ## Tokenisation strategies
|
||||
//!
|
||||
//! Merging is done on the token level, the granularity of which is
|
||||
//! configurable. By default, words are the atoms for merging and thus words
|
||||
//! can't get jumbled up at the end of reconciling.
|
||||
//! Merging happens at the token level, where you control the granularity.
|
||||
//! By default, words serve as the atomic units for merging, ensuring words
|
||||
//! remain intact during the reconciliation process.
|
||||
//!
|
||||
//! ### Built-in tokenizers
|
||||
//! ### Built-in tokenisers
|
||||
//!
|
||||
//! ```
|
||||
//! use reconcile::{reconcile, BuiltinTokenizer};
|
||||
//!
|
||||
//! let parent = "The quick brown fox\n";
|
||||
//! let left = "The very quick brown fox\n";
|
||||
//! let right = "The quick red fox\n";
|
||||
//! let left = "The very quick brown fox\n"; // Added "very"
|
||||
//! let right = "The quick red fox\n"; // Changed "brown" to "red"
|
||||
//!
|
||||
//! // Using line-based tokenisation
|
||||
//! let result = reconcile(parent, &left.into(), &right.into(), &*BuiltinTokenizer::Line);
|
||||
//! assert_eq!(result.apply().text(), "The quick red foxThe very quick brown fox\n");
|
||||
//! ```
|
||||
//!
|
||||
//! ### Custom tokenization
|
||||
//! ### Custom tokenisation
|
||||
//!
|
||||
//! If something custom is needed, for instance, to better support structured
|
||||
//! text such as Markdown or HTML, a custom tokenizer can be implemented:
|
||||
//! For specialised use cases—such as structured text like Markdown or HTML—
|
||||
//! you can implement custom tokenisation logic:
|
||||
//!
|
||||
//! ```
|
||||
//! use reconcile::{reconcile, Token, BuiltinTokenizer};
|
||||
//!
|
||||
//! // Example with custom tokenizer - split by sentences
|
||||
//! let sentence_tokenizer = |text: &str| {
|
||||
//! // Example: custom sentence-based tokeniser
|
||||
//! let sentence_tokeniser = |text: &str| {
|
||||
//! text.split(". ")
|
||||
//! .map(|sentence| Token::new(
|
||||
//! sentence.to_string(),
|
||||
//! sentence.to_string(),
|
||||
//! false, // don't allow joining token with the preceding one
|
||||
//! false, // don't allow joining token with the following one
|
||||
//! false, // don't allow joining with the preceding token
|
||||
//! false, // don't allow joining with the following token
|
||||
//! ))
|
||||
//! .collect::<Vec<_>>()
|
||||
//! };
|
||||
//!
|
||||
//! let parent = "Hello world. This is a test.";
|
||||
//! let left = "Hello beautiful world. This is a test.";
|
||||
//! let right = "Hello world. This is a great test.";
|
||||
//! let left = "Hello beautiful world. This is a test."; // Added "beautiful"
|
||||
//! let right = "Hello world. This is a great test."; // Changed "a" to "great"
|
||||
//!
|
||||
//! // Using built-in tokenizer is usually sufficient
|
||||
//! // For most cases, the built-in word tokeniser works perfectly
|
||||
//! let result = reconcile(parent, &left.into(), &right.into(), &*BuiltinTokenizer::Word);
|
||||
//! assert_eq!(result.apply().text(), "Hello beautiful world. This is a great test.");
|
||||
//! ```
|
||||
//! > By setting the joinability to `false`, longer runs of inserts will be
|
||||
//! > interleaved like LRLRLR instead of LLLRRR.
|
||||
//! > **Tip**: Setting joinability to `false` causes longer runs of insertions
|
||||
//! > to interleave (LRLRLR) rather than group together (LLLRRR), which can
|
||||
//! > produce more natural-looking merged text.
|
||||
//!
|
||||
//! ## Cursors and selection ranges
|
||||
//! ## Cursor tracking
|
||||
//!
|
||||
//! The library supports updating cursor and selection ranges during the merging
|
||||
//! for interactive workflows:
|
||||
//! Perfect for collaborative editors—the library automatically repositions
|
||||
//! cursors and selection ranges during merging:
|
||||
//!
|
||||
//! ```
|
||||
//! use reconcile::{reconcile, BuiltinTokenizer, TextWithCursors, CursorPosition};
|
||||
|
|
@ -86,21 +92,21 @@
|
|||
//! );
|
||||
//! let right = TextWithCursors::new(
|
||||
//! "Hi world".to_string(),
|
||||
//! vec![CursorPosition { id: 2, char_index: 0 }] // At beginning
|
||||
//! vec![CursorPosition { id: 2, char_index: 0 }] // At the beginning
|
||||
//! );
|
||||
//!
|
||||
//! let result = reconcile(parent, &left, &right, &*BuiltinTokenizer::Word);
|
||||
//! let merged = result.apply();
|
||||
//!
|
||||
//! assert_eq!(merged.text(), "Hi beautiful world");
|
||||
//! // Cursors are automatically repositioned
|
||||
//! // Cursors are automatically repositioned in the merged text
|
||||
//! assert_eq!(merged.cursors().len(), 2);
|
||||
//! ```
|
||||
//!
|
||||
//! ## The algorithm
|
||||
//! ## How it works
|
||||
//!
|
||||
//! For a discussion of the algorithm and architecture, see the
|
||||
//! [README](README.md#algorithm) page.
|
||||
//! For a detailed explanation of the algorithm and architecture, see the
|
||||
//! [README](README.md#how-it-works).
|
||||
|
||||
mod operation_transformation;
|
||||
mod raw_operation;
|
||||
|
|
@ -108,8 +114,8 @@ mod tokenizer;
|
|||
mod types;
|
||||
mod utils;
|
||||
|
||||
pub use operation_transformation::{EditedText, reconcile};
|
||||
pub use tokenizer::{BuiltinTokenizer, Tokenizer, token::Token};
|
||||
pub use operation_transformation::{reconcile, EditedText};
|
||||
pub use tokenizer::{token::Token, BuiltinTokenizer, Tokenizer};
|
||||
pub use types::{
|
||||
cursor_position::CursorPosition, history::History, side::Side,
|
||||
span_with_history::SpanWithHistory, text_with_cursors::TextWithCursors,
|
||||
|
|
|
|||
|
|
@ -1,142 +1,143 @@
|
|||
---
|
||||
source: src/tokenizer/character_tokenizer.rs
|
||||
expression: "character_tokenizer(\" hello, \\nwhere are you?\")"
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
Token {
|
||||
normalised: " ",
|
||||
normalized: " ",
|
||||
original: " ",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "h",
|
||||
normalized: "h",
|
||||
original: "h",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "e",
|
||||
normalized: "e",
|
||||
original: "e",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "l",
|
||||
normalized: "l",
|
||||
original: "l",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "l",
|
||||
normalized: "l",
|
||||
original: "l",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "o",
|
||||
normalized: "o",
|
||||
original: "o",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: ",",
|
||||
normalized: ",",
|
||||
original: ",",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: " ",
|
||||
normalized: " ",
|
||||
original: " ",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "\n",
|
||||
normalized: "\n",
|
||||
original: "\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "w",
|
||||
normalized: "w",
|
||||
original: "w",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "h",
|
||||
normalized: "h",
|
||||
original: "h",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "e",
|
||||
normalized: "e",
|
||||
original: "e",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "r",
|
||||
normalized: "r",
|
||||
original: "r",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "e",
|
||||
normalized: "e",
|
||||
original: "e",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: " ",
|
||||
normalized: " ",
|
||||
original: " ",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "a",
|
||||
normalized: "a",
|
||||
original: "a",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "r",
|
||||
normalized: "r",
|
||||
original: "r",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "e",
|
||||
normalized: "e",
|
||||
original: "e",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: " ",
|
||||
normalized: " ",
|
||||
original: " ",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "y",
|
||||
normalized: "y",
|
||||
original: "y",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "o",
|
||||
normalized: "o",
|
||||
original: "o",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "u",
|
||||
normalized: "u",
|
||||
original: "u",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "?",
|
||||
normalized: "?",
|
||||
original: "?",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ snapshot_kind: text
|
|||
---
|
||||
[
|
||||
Token {
|
||||
normalised: "Hello",
|
||||
normalized: "Hello",
|
||||
original: "Hello",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -5,19 +5,19 @@ snapshot_kind: text
|
|||
---
|
||||
[
|
||||
Token {
|
||||
normalised: "Hello",
|
||||
normalized: "Hello",
|
||||
original: "Hello",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "\n",
|
||||
normalized: "\n",
|
||||
original: "\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "World",
|
||||
normalized: "World",
|
||||
original: "World",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -5,25 +5,25 @@ snapshot_kind: text
|
|||
---
|
||||
[
|
||||
Token {
|
||||
normalised: "Hello",
|
||||
normalized: "Hello",
|
||||
original: "Hello",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "\n",
|
||||
normalized: "\n",
|
||||
original: "\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "World",
|
||||
normalized: "World",
|
||||
original: "World",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "\n",
|
||||
normalized: "\n",
|
||||
original: "\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -5,19 +5,19 @@ snapshot_kind: text
|
|||
---
|
||||
[
|
||||
Token {
|
||||
normalised: "Line 1",
|
||||
normalized: "Line 1",
|
||||
original: "Line 1",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "\r\n",
|
||||
normalized: "\r\n",
|
||||
original: "\r\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "Line 2",
|
||||
normalized: "Line 2",
|
||||
original: "Line 2",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -5,43 +5,43 @@ snapshot_kind: text
|
|||
---
|
||||
[
|
||||
Token {
|
||||
normalised: "Multi",
|
||||
normalized: "Multi",
|
||||
original: "Multi",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "\n",
|
||||
normalized: "\n",
|
||||
original: "\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "Line",
|
||||
normalized: "Line",
|
||||
original: "Line",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "\n",
|
||||
normalized: "\n",
|
||||
original: "\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "Text",
|
||||
normalized: "Text",
|
||||
original: "Text",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "\n",
|
||||
normalized: "\n",
|
||||
original: "\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "Here",
|
||||
normalized: "Here",
|
||||
original: "Here",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ snapshot_kind: text
|
|||
---
|
||||
[
|
||||
Token {
|
||||
normalised: "\n",
|
||||
normalized: "\n",
|
||||
original: "\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ snapshot_kind: text
|
|||
---
|
||||
[
|
||||
Token {
|
||||
normalised: "\n",
|
||||
normalized: "\n",
|
||||
original: "\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "\n",
|
||||
normalized: "\n",
|
||||
original: "\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -5,25 +5,25 @@ snapshot_kind: text
|
|||
---
|
||||
[
|
||||
Token {
|
||||
normalised: "Start",
|
||||
normalized: "Start",
|
||||
original: "Start",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "\n",
|
||||
normalized: "\n",
|
||||
original: "\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "\n",
|
||||
normalized: "\n",
|
||||
original: "\n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "End",
|
||||
normalized: "End",
|
||||
original: "End",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
---
|
||||
source: reconcile/src/tokenizer/word_tokenizer.rs
|
||||
source: src/tokenizer/word_tokenizer.rs
|
||||
expression: "word_tokenizer(\" what? \")"
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
Token {
|
||||
normalised: " what?",
|
||||
normalized: " what?",
|
||||
original: " ",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "what?",
|
||||
normalized: "what?",
|
||||
original: "what?",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: " ",
|
||||
normalized: " ",
|
||||
original: " ",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -1,53 +1,53 @@
|
|||
---
|
||||
source: reconcile/src/tokenizer/word_tokenizer.rs
|
||||
source: src/tokenizer/word_tokenizer.rs
|
||||
expression: "word_tokenizer(\" hello, \\nwhere are you?\")"
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
Token {
|
||||
normalised: " hello,",
|
||||
normalized: " hello,",
|
||||
original: " ",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "hello,",
|
||||
normalized: "hello,",
|
||||
original: "hello,",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: " \nwhere",
|
||||
normalized: " \nwhere",
|
||||
original: " \n",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "where",
|
||||
normalized: "where",
|
||||
original: "where",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: " are",
|
||||
normalized: " are",
|
||||
original: " ",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "are",
|
||||
normalized: "are",
|
||||
original: "are",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: " you?",
|
||||
normalized: " you?",
|
||||
original: " ",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "you?",
|
||||
normalized: "you?",
|
||||
original: "you?",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
---
|
||||
source: reconcile/src/tokenizer/word_tokenizer.rs
|
||||
source: src/tokenizer/word_tokenizer.rs
|
||||
expression: "word_tokenizer(\"Hi there!\")"
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
Token {
|
||||
normalised: "Hi",
|
||||
normalized: "Hi",
|
||||
original: "Hi",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: " there!",
|
||||
normalized: " there!",
|
||||
original: " ",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
},
|
||||
Token {
|
||||
normalised: "there!",
|
||||
normalized: "there!",
|
||||
original: "there!",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
---
|
||||
source: src/utils/myers_diff.rs
|
||||
expression: result
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
Equal(
|
||||
[
|
||||
Token {
|
||||
normalised: "a",
|
||||
normalized: "a",
|
||||
original: "a",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -16,7 +17,7 @@ expression: result
|
|||
Insert(
|
||||
[
|
||||
Token {
|
||||
normalised: "x",
|
||||
normalized: "x",
|
||||
original: "x",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -26,7 +27,7 @@ expression: result
|
|||
Delete(
|
||||
[
|
||||
Token {
|
||||
normalised: "b",
|
||||
normalized: "b",
|
||||
original: "b",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -36,7 +37,7 @@ expression: result
|
|||
Equal(
|
||||
[
|
||||
Token {
|
||||
normalised: "c",
|
||||
normalized: "c",
|
||||
original: "c",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -46,7 +47,7 @@ expression: result
|
|||
Insert(
|
||||
[
|
||||
Token {
|
||||
normalised: "y",
|
||||
normalized: "y",
|
||||
original: "y",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -56,7 +57,7 @@ expression: result
|
|||
Delete(
|
||||
[
|
||||
Token {
|
||||
normalised: "d",
|
||||
normalized: "d",
|
||||
original: "d",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
---
|
||||
source: src/utils/myers_diff.rs
|
||||
expression: result
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
Delete(
|
||||
[
|
||||
Token {
|
||||
normalised: "a",
|
||||
normalized: "a",
|
||||
original: "a",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -16,7 +17,7 @@ expression: result
|
|||
Delete(
|
||||
[
|
||||
Token {
|
||||
normalised: "b",
|
||||
normalized: "b",
|
||||
original: "b",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
---
|
||||
source: src/utils/myers_diff.rs
|
||||
expression: result
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
Equal(
|
||||
[
|
||||
Token {
|
||||
normalised: "a",
|
||||
normalized: "a",
|
||||
original: "a",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -16,7 +17,7 @@ expression: result
|
|||
Equal(
|
||||
[
|
||||
Token {
|
||||
normalised: "b",
|
||||
normalized: "b",
|
||||
original: "b",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -26,7 +27,7 @@ expression: result
|
|||
Equal(
|
||||
[
|
||||
Token {
|
||||
normalised: "c",
|
||||
normalized: "c",
|
||||
original: "c",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
---
|
||||
source: src/utils/myers_diff.rs
|
||||
expression: result
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
Insert(
|
||||
[
|
||||
Token {
|
||||
normalised: "a",
|
||||
normalized: "a",
|
||||
original: "a",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -16,7 +17,7 @@ expression: result
|
|||
Insert(
|
||||
[
|
||||
Token {
|
||||
normalised: "b",
|
||||
normalized: "b",
|
||||
original: "b",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
---
|
||||
source: src/utils/myers_diff.rs
|
||||
expression: result
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
Equal(
|
||||
[
|
||||
Token {
|
||||
normalised: "a",
|
||||
normalized: "a",
|
||||
original: "a",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -16,7 +17,7 @@ expression: result
|
|||
Delete(
|
||||
[
|
||||
Token {
|
||||
normalised: "b",
|
||||
normalized: "b",
|
||||
original: "b",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -26,7 +27,7 @@ expression: result
|
|||
Delete(
|
||||
[
|
||||
Token {
|
||||
normalised: "c",
|
||||
normalized: "c",
|
||||
original: "c",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -36,7 +37,7 @@ expression: result
|
|||
Insert(
|
||||
[
|
||||
Token {
|
||||
normalised: "x",
|
||||
normalized: "x",
|
||||
original: "x",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
@ -46,7 +47,7 @@ expression: result
|
|||
Equal(
|
||||
[
|
||||
Token {
|
||||
normalised: "d",
|
||||
normalized: "d",
|
||||
original: "d",
|
||||
is_left_joinable: true,
|
||||
is_right_joinable: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue