Skip to content

Commit

Permalink
Replace minus 2 plus 2 logic with boolean expression
Browse files Browse the repository at this point in the history
  • Loading branch information
meyermarcel committed Jun 6, 2024
1 parent 9128676 commit 3ced6b0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions annot.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,18 @@ func checkLineAndSetSpace(row, aLineIdx int, a *Annot, rightAnnots []*Annot) boo
// linesAfterSecond | line3
//
// █ = needed space
if s == above || s == linesFirstTwo {
remainingSpaces -= 2
}
tooLongForAboveOrLinesFirstTwo := (s == above || s == linesFirstTwo) && remainingSpaces < 2

if remainingSpaces < 0 {
if remainingSpaces < 0 || tooLongForAboveOrLinesFirstTwo {
a.row++
a.pipeLeadingSpaces = append(a.pipeLeadingSpaces, a.Col)
return false
}

switch s {
case above:
closestA.pipeLeadingSpaces[rowPlusLineIdx] = remainingSpaces + 2
case linesFirstTwo:
closestA.lines[rowPlusLineIdx-closestA.row].leadingSpaces = remainingSpaces + 2
case linesAfterSecond:
closestA.pipeLeadingSpaces[rowPlusLineIdx] = remainingSpaces
case linesFirstTwo, linesAfterSecond:
closestA.lines[rowPlusLineIdx-closestA.row].leadingSpaces = remainingSpaces
case trailingSpaceLines:
closestA2, s2 := closestAnnot(rowPlusLineIdx, rightAnnots, 0)
Expand Down

0 comments on commit 3ced6b0

Please sign in to comment.