Fix parsing large notes (#339)

pull/344/head
khimaros 9 months ago committed by GitHub
parent 072fae2f6c
commit 0b4db9ade6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,7 +2,11 @@
All notable changes to this project will be documented in this file.
<!--## Unreleased-->
## Unreleased
### Fixed
* [#331](https://github.com/mickael-menu/zk/issues/331) Fixed parsing large notes (contributed by [@khimaros](https://github.com/mickael-menu/zk/pull/339)).
## 0.14.0

@ -2,6 +2,7 @@ package strings
import (
"bufio"
"log"
"net/url"
"regexp"
"strconv"
@ -37,9 +38,15 @@ func Pluralize(word string, count int) string {
func SplitLines(s string) []string {
var lines []string
scanner := bufio.NewScanner(strings.NewReader(s))
// increase the buffer size to 2Mb
buf := []byte{}
scanner.Buffer(buf, 2048*1024)
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
if err := scanner.Err(); err != nil {
log.Fatalf("error while scanning text: %v", err)
}
return lines
}

Loading…
Cancel
Save