Skip to content

Commit

Permalink
fix: comment line do not get correct when more than one comment multi…
Browse files Browse the repository at this point in the history
…lines are defined
  • Loading branch information
hhatto committed Sep 24, 2020
1 parent 74e46c8 commit fb5b473
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ scannerloop:
continue scannerloop
}

isCode := false
lenLine := len(line)
if len(language.multiLines) == 1 && len(language.multiLines[0]) == 2 && language.multiLines[0][0] == "" {
onCode(clocFile, opts, len(inComments) > 0, line, lineOrg)
continue
}
codeFlags := make([]bool, len(language.multiLines))
for pos := 0; pos < lenLine; {
for _, ml := range language.multiLines {
for idx, ml := range language.multiLines {
begin, end := ml[0], ml[1]
lenBegin := len(begin)

Expand All @@ -135,12 +135,19 @@ scannerloop:
pos += len(last[1])
}
} else if pos < lenLine && !unicode.IsSpace(nextRune(line[pos:])) {
isCode = true
codeFlags[idx] = true
}
}
pos++
}

isCode := true
for _, b := range codeFlags {
if b == false {
isCode = false
}
}

if isCode {
onCode(clocFile, opts, len(inComments) > 0, line, lineOrg)
} else {
Expand Down

0 comments on commit fb5b473

Please sign in to comment.