diff --git a/CHANGELOG.md b/CHANGELOG.md index b25cfeb..b983e54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,11 @@ All notable changes to this project will be documented in this file. - +## 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 diff --git a/internal/util/strings/strings.go b/internal/util/strings/strings.go index be5f406..4db54c4 100644 --- a/internal/util/strings/strings.go +++ b/internal/util/strings/strings.go @@ -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 }