@@ -868,7 +868,6 @@ func ExcerptBlob(ctx *context.Context) {
868868 lastRightCommentIdx := ctx .FormInt ("last_left_comment_idx" )
869869 rightCommentIdx := ctx .FormInt ("left_comment_idx" )
870870 fileName := ctx .FormString ("file_name" )
871-
872871 if ctx .FormBool ("pull" ) {
873872 ctx .Data ["PageIsPullFiles" ] = true
874873 }
@@ -891,6 +890,10 @@ func ExcerptBlob(ctx *context.Context) {
891890 }
892891
893892 allComments , err := issues_model .FetchCodeComments (ctx , issue , ctx .Doer , false )
893+ if err != nil {
894+ ctx .ServerError ("FetchCodeComments" , err )
895+ return
896+ }
894897 lineCommits := allComments [fileName ]
895898
896899 chunkSize := gitdiff .BlobExcerptChunkSize
@@ -958,30 +961,19 @@ func ExcerptBlob(ctx *context.Context) {
958961 section .Lines = append (section .Lines , lineSection )
959962 }
960963 }
961-
962964 for _ , line := range section .Lines {
963965 if line .SectionInfo != nil {
964- //for now considerign only right side.
965966 start := int64 (line .SectionInfo .LastRightIdx + 1 )
966967 end := int64 (line .SectionInfo .RightIdx - 1 )
967-
968- //to check section has comments or not.
969- //1. we can use binary search
970- //2. we can LastRightCommentIdx, RightCommentIdx, LastLeftCommentIdx, LeftCommentIdx(little complex but fast)
971- //3. for demo using linear search
972968 for start <= end {
973969 if _ , ok := lineCommits [start ]; ok {
974970 if ! line .SectionInfo .HasComments {
975- // line.SectionInfo.LastRightCommentIdx = int(start)
976- // line.SectionInfo.RightCommentIdx = int(start)
977971 line .SectionInfo .HasComments = true
978972 break
979973 }
980-
981974 }
982- start += 1
975+ start ++
983976 }
984-
985977 }
986978 if comments , ok := lineCommits [int64 (line .LeftIdx * - 1 )]; ok {
987979 line .Comments = append (line .Comments , comments ... )
@@ -994,7 +986,6 @@ func ExcerptBlob(ctx *context.Context) {
994986 return line .Comments [i ].CreatedUnix < line .Comments [j ].CreatedUnix
995987 })
996988 }
997-
998989 for _ , line := range section .Lines {
999990 for _ , comment := range line .Comments {
1000991 if err := comment .LoadAttachments (ctx ); err != nil {
@@ -1003,18 +994,15 @@ func ExcerptBlob(ctx *context.Context) {
1003994 }
1004995 }
1005996 }
1006-
1007997 ctx .Data ["section" ] = section
1008998 ctx .Data ["FileNameHash" ] = git .HashFilePathForWebUI (filePath )
1009999 ctx .Data ["AfterCommitID" ] = commitID
10101000 ctx .Data ["Anchor" ] = anchor
10111001 ctx .Data ["Issue" ] = issue
10121002 ctx .Data ["issue" ] = issue .Index
1013- ctx .Data ["SignedUserID" ] = ctx .Data ["SignedUserID" ]
10141003 ctx .Data ["CanBlockUser" ] = func (blocker , blockee * user_model.User ) bool {
10151004 return user_service .CanBlockUser (ctx , ctx .Doer , blocker , blockee )
10161005 }
1017-
10181006 if ctx .Data ["SignedUserID" ] == nil {
10191007 ctx .Data ["SignedUserID" ] = ctx .Doer .ID
10201008 }
0 commit comments