@@ -871,32 +871,36 @@ function parseReview(
871
871
function removeLineNumbersFromSuggestion ( comment : string ) : string {
872
872
const suggestionStart = '```suggestion'
873
873
const suggestionEnd = '```'
874
- const suggestionStartIndex = comment . indexOf ( suggestionStart )
874
+ let suggestionStartIndex = comment . indexOf ( suggestionStart )
875
875
876
- if ( suggestionStartIndex === - 1 ) {
877
- return comment
878
- }
876
+ while ( suggestionStartIndex !== - 1 ) {
877
+ const suggestionEndIndex = comment . indexOf (
878
+ suggestionEnd ,
879
+ suggestionStartIndex
880
+ )
881
+ const suggestionBlock = comment . substring (
882
+ suggestionStartIndex + suggestionStart . length ,
883
+ suggestionEndIndex
884
+ )
885
+ const lineNumberRegex = / ^ \s * \d + : \s + /
879
886
880
- const suggestionEndIndex = comment . indexOf (
881
- suggestionEnd ,
882
- suggestionStartIndex
883
- )
884
- const suggestionBlock = comment . substring (
885
- suggestionStartIndex + suggestionStart . length ,
886
- suggestionEndIndex
887
- )
888
- const lineNumberRegex = / ^ \s * \d + : \s + /
887
+ const sanitizedBlock = suggestionBlock
888
+ . split ( '\n' )
889
+ . map ( line => line . replace ( lineNumberRegex , '' ) )
890
+ . join ( '\n' )
889
891
890
- const sanitizedBlock = suggestionBlock
891
- . split ( '\n' )
892
- . map ( line => line . replace ( lineNumberRegex , '' ) )
893
- . join ( '\n' )
892
+ comment =
893
+ comment . substring ( 0 , suggestionStartIndex + suggestionStart . length ) +
894
+ sanitizedBlock +
895
+ comment . substring ( suggestionEndIndex )
894
896
895
- return (
896
- comment . substring ( 0 , suggestionStartIndex + suggestionStart . length ) +
897
- sanitizedBlock +
898
- comment . substring ( suggestionEndIndex )
899
- )
897
+ suggestionStartIndex = comment . indexOf (
898
+ suggestionStart ,
899
+ suggestionEndIndex + suggestionEnd . length
900
+ )
901
+ }
902
+
903
+ return comment
900
904
}
901
905
902
906
function storeReview ( ) : void {
@@ -944,11 +948,9 @@ ${review.comment}`
944
948
945
949
reviews . push ( review )
946
950
947
- if ( debug ) {
948
- core . info (
949
- `Stored comment for line range ${ currentStartLine } -${ currentEndLine } : ${ currentComment . trim ( ) } `
950
- )
951
- }
951
+ core . info (
952
+ `Stored comment for line range ${ currentStartLine } -${ currentEndLine } : ${ currentComment . trim ( ) } `
953
+ )
952
954
}
953
955
}
954
956
0 commit comments