Fix EOF handling in TextFragment#ApplyStrict

io.EOF was not properly accounted for when dealing with patches that are
missing trailing newline characters.
This commit is contained in:
Billy Keyes
2020-01-09 22:05:24 -08:00
parent 02f7ff4f79
commit 7bd4e0bb0e
9 changed files with 70 additions and 23 deletions
+15
View File
@@ -137,6 +137,21 @@ func (fl Line) String() string {
return fl.Op.String() + fl.Line
}
// Old returns true if the line appears in the old content of the fragment.
func (fl Line) Old() bool {
return fl.Op != OpAdd
}
// New returns true if the line appears in the new content of the fragment.
func (fl Line) New() bool {
return fl.Op == OpAdd
}
// NoEOL returns true if the line is missing a trailing newline character.
func (fl Line) NoEOL() bool {
return len(fl.Line) == 0 || fl.Line[len(fl.Line)-1] != '\n'
}
// LineOp describes the type of a text fragment line: context, added, or removed.
type LineOp int