Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reconcile pending comments in comment threads #197146

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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