diff options
Diffstat (limited to 'bug/op_edit_comment.go')
-rw-r--r-- | bug/op_edit_comment.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/bug/op_edit_comment.go b/bug/op_edit_comment.go index 49b6a1af..01832959 100644 --- a/bug/op_edit_comment.go +++ b/bug/op_edit_comment.go @@ -36,7 +36,6 @@ func (op *EditCommentOperation) Apply(snapshot *Snapshot) { snapshot.addActor(op.Author) var target TimelineItem - var commentIndex int for i, item := range snapshot.Timeline { h := item.Hash() @@ -45,12 +44,6 @@ func (op *EditCommentOperation) Apply(snapshot *Snapshot) { target = snapshot.Timeline[i] break } - - // Track the index in the []Comment - switch item.(type) { - case *CreateTimelineItem, *AddCommentTimelineItem: - commentIndex++ - } } if target == nil { @@ -75,8 +68,15 @@ func (op *EditCommentOperation) Apply(snapshot *Snapshot) { item.Append(comment) } - snapshot.Comments[commentIndex].Message = op.Message - snapshot.Comments[commentIndex].Files = op.Files + // Updating the corresponding comment + + for i := range snapshot.Comments { + if snapshot.Comments[i].Id() == string(op.Target) { + snapshot.Comments[i].Message = op.Message + snapshot.Comments[i].Files = op.Files + break + } + } } func (op *EditCommentOperation) GetFiles() []git.Hash { |