textmerge

package
v0.18.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package textmerge is the line-based three-way merge shared by the sync engine (two devices' concurrent puts) and the hub (an outside write landing under a live co-editing room).

Hand-written, no dependency: the code that decides what a merged file contains should be readable in one sitting. Line-based on purpose. Word- or character-level merging resolves more cases and silently produces sentences neither author wrote; a line is the unit people actually edit, and anything overlapping is left to the caller's conflict path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsText

func IsText(b []byte) bool

IsText reports whether b is something a line merge may touch: valid UTF-8 with no NUL. Merging bytes that are not lines produces a file that is neither side's, and for a binary format that means a corrupt one.

func Merge

func Merge(base, a, b []byte) ([]byte, bool)

Merge merges two edits of the same base. ok is false when the two sides changed the same region, which is a real conflict and stays one.

Determinism matters more than cleverness here: two devices can each observe the same concurrency and merge independently, so merge(base, a, b) and merge(base, b, a) must agree or the fleet diverges. Only NON-overlapping hunks are ever taken, which makes the result the union either way.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL