@@ -239,20 +239,31 @@ func UpdateCommentContent(ctx *context.Context) {
239239 return
240240 }
241241
242- oldContent := comment .Content
243242 newContent := ctx .FormString ("content" )
244243 contentVersion := ctx .FormInt ("content_version" )
245- if newContent == oldContent {
244+ if newContent == comment .Content {
245+ if contentVersion != comment .ContentVersion {
246+ ctx .JSONError (ctx .Tr ("repo.comments.edit.already_changed" ))
247+ return
248+ }
249+
250+ if err := comment .LoadAttachments (ctx ); err != nil {
251+ ctx .ServerError ("LoadAttachments" , err )
252+ return
253+ }
254+
246255 ctx .JSON (http .StatusOK , map [string ]any {
247- "content" : oldContent ,
256+ "content" : comment . Content ,
248257 "contentVersion" : comment .ContentVersion ,
249- "attachments" : attachmentsHTML (ctx , comment .Attachments , oldContent ),
258+ "attachments" : attachmentsHTML (ctx , comment .Attachments , comment . Content ),
250259 })
251260 return
252261 }
253262
254263 // allow to save empty content
255264 comment .Content = newContent
265+ oldContent := comment .Content
266+
256267 if err = issue_service .UpdateComment (ctx , comment , contentVersion , ctx .Doer , oldContent ); err != nil {
257268 if errors .Is (err , user_model .ErrBlockedUser ) {
258269 ctx .JSONError (ctx .Tr ("repo.issues.comment.blocked_user" ))
0 commit comments