Skip to content

Commit

Permalink
Use ScanLinesAndTruncateWhenLongerThanBuffer instead of bufio.ScanLines
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhaller committed May 15, 2024
1 parent e0a2d97 commit f69eb6d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/commands/oscommands/cmd_obj_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (self *cmdObjRunner) RunAndProcessLines(cmdObj ICmdObj, onLine func(line st
}

scanner := bufio.NewScanner(stdoutPipe)
scanner.Split(bufio.ScanLines)
scanner.Split(utils.ScanLinesAndTruncateWhenLongerThanBuffer(bufio.MaxScanTokenSize))
if err := cmd.Start(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/mergeconflicts/find_conflicts.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func FileHasConflictMarkers(path string) (bool, error) {
// Efficiently scans through a file looking for merge conflict markers. Returns true if it does
func fileHasConflictMarkersAux(file io.Reader) bool {
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
scanner.Split(utils.ScanLinesAndTruncateWhenLongerThanBuffer(bufio.MaxScanTokenSize))
for scanner.Scan() {
line := scanner.Bytes()

Expand Down
2 changes: 1 addition & 1 deletion pkg/tasks/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), p
done := make(chan struct{})

scanner := bufio.NewScanner(r)
scanner.Split(bufio.ScanLines)
scanner.Split(utils.ScanLinesAndTruncateWhenLongerThanBuffer(bufio.MaxScanTokenSize))

lineChan := make(chan []byte)
lineWrittenChan := make(chan struct{})
Expand Down

0 comments on commit f69eb6d

Please sign in to comment.