mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 14:40:20 +09:00
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:
@@ -658,7 +658,11 @@ func calcHash(b *Buffer, out *[md5.Size]byte) error {
|
||||
size += n
|
||||
|
||||
for _, l := range b.lines[1:] {
|
||||
n, _ = h.Write([]byte{'\n'})
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user