calcHash: use correct line endings

Make calcHash() respect the buffer's file endings (unix vs dos), to make
its calculation of the file size consistent with how we calculate it in
other cases (i.e. when opening or saving the file) and with the
`fastdirty` option documentation, i.e. make calcHash() return
ErrFileTooLarge if and only if the exact file size exceeds 50KB.
This commit is contained in:
Dmytro Maluka 2024-08-17 16:56:15 +02:00
parent e0f5361d97
commit c0f6b65ed6

View File

@ -658,7 +658,11 @@ func calcHash(b *Buffer, out *[md5.Size]byte) error {
size += n
for _, l := range b.lines[1:] {
if b.Endings == FFDos {
n, _ = h.Write([]byte{'\r', '\n'})
} else {
n, _ = h.Write([]byte{'\n'})
}
size += n
n, _ = h.Write(l.data)
size += n