Commit de97637a authored by Jacob Vosmaer's avatar Jacob Vosmaer

this crashes

parent b9f15d59
......@@ -43,11 +43,18 @@ func stripTrailingWhitespace(id int, name string) {
return
}
newContent := make([]byte, len(oldContent))
newContent := make([]byte, 0, len(oldContent))
scanner := bufio.NewScanner(bytes.NewReader(oldContent))
lastChanged := 0
line := 0
for scanner.Scan() {
newContent = append(newContent, bytes.TrimRight(scanner.Bytes(), " ")...)
newLineContent := bytes.TrimRight(scanner.Bytes(), " ")
if !bytes.Equal(newLineContent, scanner.Bytes()) {
lastChanged = line
}
newContent = append(newContent, newLineContent...)
newContent = append(newContent, '\n')
line++
}
if scanner.Err() != nil {
log.Print(err)
......@@ -90,7 +97,8 @@ func stripTrailingWhitespace(id int, name string) {
return
}
if err := w.Addr("%d,%d", q0, q1); err != nil {
log.Print(lastChanged)
if err := w.Addr("%d,0", lastChanged); err != nil {
log.Print(err)
return
}
......@@ -99,5 +107,9 @@ func stripTrailingWhitespace(id int, name string) {
log.Print(err)
return
}
if _, err := w.Write("ctl", []byte("show")); err != nil {
log.Print(err)
return
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment