textutil

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package textutil holds text-shaping helpers shared by jade's response builders.

Index

Constants

View Source
const ClampHeadFraction = 0.4

ClampHeadFraction splits a clamp budget between the start and end of the text. Both ends matter for tool output: compilers report the first failure first, `go test` prints its FAIL summary last, and a diff's first and last hunks are equally likely to be the interesting one — so keeping only one end reliably loses the decisive part for some caller.

Variables

This section is empty.

Functions

func Clamp

func Clamp(text string, maxBytes int, hint string) (string, int)

Clamp bounds text to maxBytes, keeping the head and the tail and replacing the middle with an explicit marker naming what was dropped. It returns the clamped text and the number of bytes omitted (0 when nothing was cut).

Cuts land on line boundaries wherever possible: a raw byte cut can split a UTF-8 rune or leave a half-written path, which costs a reader more than the few bytes it saves.

Truncation is always visible. A reader who cannot see that bytes are missing will read the remainder as complete, which is a worse failure than returning less.

Types

This section is empty.

Jump to

Keyboard shortcuts

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