Skip to content

Commit

Permalink
Add comment thread pending comment reconciliation
Browse files Browse the repository at this point in the history
Fixes #196574
  • Loading branch information
alexr00 committed Nov 1, 2023
1 parent be84baa commit 70af91c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/vs/workbench/contrib/comments/browser/commentsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,20 @@ export class CommentController implements IEditorContribution {
const matchedZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === thread.owner && Range.lift(zoneWidget.commentThread.range)?.equalsRange(thread.range));
if (thread.isReply && matchedZones.length) {
this.commentService.removeContinueOnComment({ owner: thread.owner, uri: editorURI, range: thread.range, isReply: true });
const matchedZone = matchedZones[0];
matchedZone.setPendingComment(thread.body);
matchedZones[0].setPendingComment(thread.body);
} else if (matchedZones.length) {
this.commentService.removeContinueOnComment({ owner: thread.owner, uri: editorURI, range: thread.range, isReply: false });
const existingPendingComment = matchedZones[0].getPendingComments().newComment;
// We need to try to reconcile the existing pending comment with the incoming pending comment
let pendingComment: string;
if (!existingPendingComment || thread.body.includes(existingPendingComment)) {
pendingComment = thread.body;
} else if (existingPendingComment.includes(thread.body)) {
pendingComment = existingPendingComment;
} else {
pendingComment = `${existingPendingComment}\n${thread.body}`;
}
matchedZones[0].setPendingComment(pendingComment);
} else if (!thread.isReply) {
const threadStillAvailable = this.commentService.removeContinueOnComment({ owner: thread.owner, uri: editorURI, range: thread.range, isReply: false });
if (!threadStillAvailable) {
Expand Down

0 comments on commit 70af91c

Please sign in to comment.