MCPcopy Index your code
hub / github.com/codehamr/codehamr / differsOnlyInWhitespace

Function differsOnlyInWhitespace

internal/tools/edit.go:68–71  ·  view source on GitHub ↗

differsOnlyInWhitespace reports whether oldString matches content at exactly one spot once every whitespace run is collapsed: i.e. the sole mismatch is indentation/tabs/newlines. Bounded with spaces so a match can't straddle a token boundary and mislabel an unrelated near-miss.

(content, oldString string)

Source from the content-addressed store, hash-verified

66// indentation/tabs/newlines. Bounded with spaces so a match can't straddle a
67// token boundary and mislabel an unrelated near-miss.
68func differsOnlyInWhitespace(content, oldString string) bool {
69 norm := func(s string) string { return " " + strings.Join(strings.Fields(s), " ") + " " }
70 return strings.Count(norm(content), norm(oldString)) == 1
71}
72
73// EditFileSchema is the OpenAI tool definition for edit_file. The description
74// steers the model toward edit_file over write_file for small changes so it

Callers 1

EditFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected