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)
| 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. |
| 718 | func 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. |
no test coverage detected