Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increase buffer size to 2MB and display an error when it is exhausted #339

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions internal/util/strings/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package strings

import (
"bufio"
"log"
"net/url"
"regexp"
"strconv"
Expand Down Expand Up @@ -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
}

Expand Down