Skip to content

Commit 52ad1ed

Browse files
fix: adjust column index in first line
1 parent 4c6bd39 commit 52ad1ed

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

engine/engine.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,18 @@ func buildSecret(ctx context.Context, item plugins.ISourceItem, value report.Fin
324324
return nil, fmt.Errorf("failed to get line content for source %s: %w", item.GetSource(), err)
325325
}
326326

327-
cleanLineContent := strings.ReplaceAll(lineContent, "\n", "")
327+
hasNewline := strings.HasPrefix(lineContent, "\n")
328+
329+
cleanLineContent := lineContent
330+
if hasNewline {
331+
cleanLineContent = strings.TrimPrefix(cleanLineContent, "\n")
332+
}
328333
cleanLineContent = strings.ReplaceAll(cleanLineContent, "\r", "")
329334

330335
adjustedStartColumn := value.StartColumn
331336
adjustedEndColumn := value.EndColumn
332-
if adjustedStartColumn > 0 {
337+
if hasNewline {
333338
adjustedStartColumn--
334-
}
335-
if adjustedEndColumn > 0 {
336339
adjustedEndColumn--
337340
}
338341

0 commit comments

Comments
 (0)