mirror of
https://github.com/zyedidia/micro.git
synced 2025-06-19 07:15:34 -04: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:
parent
e0f5361d97
commit
c0f6b65ed6
@ -658,7 +658,11 @@ func calcHash(b *Buffer, out *[md5.Size]byte) error {
|
|||||||
size += n
|
size += n
|
||||||
|
|
||||||
for _, l := range b.lines[1:] {
|
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
|
size += n
|
||||||
n, _ = h.Write(l.data)
|
n, _ = h.Write(l.data)
|
||||||
size += n
|
size += n
|
||||||
|
Loading…
Reference in New Issue
Block a user