MCPcopy Create free account
hub / github.com/sergi/go-diff / alignRuneEnd

Function alignRuneEnd

diffmatchpatch/patch.go:49–54  ·  view source on GitHub ↗

alignRuneEnd moves byte index idx forward to the next UTF-8 rune start. idx <= 0 or idx >= len(s) is returned unchanged.

(s string, idx int)

Source from the content-addressed store, hash-verified

47// alignRuneEnd moves byte index idx forward to the next UTF-8 rune start.
48// idx <= 0 or idx >= len(s) is returned unchanged.
49func alignRuneEnd(s string, idx int) int {
50 for idx > 0 && idx < len(s) && !utf8.RuneStart(s[idx]) {
51 idx++
52 }
53 return idx
54}
55
56// Patch represents one patch operation.
57type Patch struct {

Callers 3

PatchAddContextMethod · 0.85
PatchApplyMethod · 0.85
TestAlignRuneEndFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestAlignRuneEndFunction · 0.68