Skip to content

Commit

Permalink
Fix parsing large notes (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
khimaros authored Aug 15, 2023
1 parent 072fae2 commit 0b4db9a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit 0b4db9a

Please sign in to comment.