MCPcopy Create free account
hub / github.com/coder/coder / atNoNewlineEOF

Function atNoNewlineEOF

agent/agentfiles/files.go:718–733  ·  view source on GitHub ↗

atNoNewlineEOF reports whether the matched region ends at a file that lacks a trailing newline. True when no non-empty lines follow the match and the last matched line has no ending.

(contentLines []string, end int)

Source from the content-addressed store, hash-verified

716// file that lacks a trailing newline. True when no non-empty lines
717// follow the match and the last matched line has no ending.
718func atNoNewlineEOF(contentLines []string, end int) bool {
719 if end == 0 {
720 return false
721 }
722 if end < len(contentLines) {
723 // Anything non-empty after the match disqualifies.
724 for _, l := range contentLines[end:] {
725 if l != "" {
726 return false
727 }
728 }
729 }
730 // Last matched content line must itself have no ending.
731 _, e := splitEnding(contentLines[end-1])
732 return e == ""
733}
734
735// leadOnly returns the leading whitespace of line (spaces and
736// tabs only), excluding the ending.

Callers 1

fuzzyReplaceLinesFunction · 0.85

Calls 1

splitEndingFunction · 0.85

Tested by

no test coverage detected