diff --git a/src/vs/workbench/api/browser/mainThreadComments.ts b/src/vs/workbench/api/browser/mainThreadComments.ts index 9a6f866362c..0c7ebab1417 100644 --- a/src/vs/workbench/api/browser/mainThreadComments.ts +++ b/src/vs/workbench/api/browser/mainThreadComments.ts @@ -451,6 +451,10 @@ export class MainThreadCommentController { this._proxy.$createCommentThreadTemplate(this.handle, resource, range); } + async updateCommentThreadTemplate(threadHandle: number, range: IRange) { + await this._proxy.$updateCommentThreadTemplate(this.handle, threadHandle, range); + } + toJSON(): any { return { $mid: 6, diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index ed5dec5a66f..8379c584038 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -1210,6 +1210,7 @@ export interface ExtHostCommentsShape { $provideDocumentComments(handle: number, document: UriComponents): Promise; $createNewCommentThread(handle: number, document: UriComponents, range: IRange, text: string): Promise; $createCommentThreadTemplate(commentControllerHandle: number, uriComponents: UriComponents, range: IRange): void; + $updateCommentThreadTemplate(commentControllerHandle: number, threadHandle: number, range: IRange): Promise; $onCommentWidgetInputChange(commentControllerHandle: number, document: UriComponents, range: IRange, input: string | undefined): Promise; $deleteCommentThread(commentControllerHandle: number, commentThreadHandle: number): void; $provideCommentingRanges(commentControllerHandle: number, uriComponents: UriComponents, token: CancellationToken): Promise; diff --git a/src/vs/workbench/api/common/extHostComments.ts b/src/vs/workbench/api/common/extHostComments.ts index 9276ca5f685..ca19cf7afcf 100644 --- a/src/vs/workbench/api/common/extHostComments.ts +++ b/src/vs/workbench/api/common/extHostComments.ts @@ -162,6 +162,16 @@ export class ExtHostComments implements ExtHostCommentsShape { commentController.$createCommentThreadTemplate(uriComponents, range); } + async $updateCommentThreadTemplate(commentControllerHandle: number, threadHandle: number, range: IRange) { + const commentController = this._commentControllers.get(commentControllerHandle); + + if (!commentController) { + return; + } + + commentController.$updateCommentThreadTemplate(threadHandle, range); + } + $onCommentWidgetInputChange(commentControllerHandle: number, uriComponents: UriComponents, range: IRange, input: string): Promise { const commentController = this._commentControllers.get(commentControllerHandle); @@ -772,6 +782,13 @@ class ExtHostCommentController implements vscode.CommentController { return commentThread; } + $updateCommentThreadTemplate(threadHandle: number, range: IRange) { + let thread = this._threads.get(threadHandle); + if (thread) { + thread.range = extHostTypeConverter.Range.to(range); + } + } + $deleteCommentThread(threadHandle: number) { let thread = this._threads.get(threadHandle); diff --git a/src/vs/workbench/browser/web.simpleservices.ts b/src/vs/workbench/browser/web.simpleservices.ts index 3920c5d2d31..cbc3ed62e7d 100644 --- a/src/vs/workbench/browser/web.simpleservices.ts +++ b/src/vs/workbench/browser/web.simpleservices.ts @@ -628,6 +628,7 @@ export class SimpleCommentService implements ICommentService { unregisterCommentController: any; getCommentController: any; createCommentThreadTemplate: any; + updateCommentThreadTemplate: any; getCommentMenus: any; registerDataProvider: any; unregisterDataProvider: any; diff --git a/src/vs/workbench/contrib/comments/browser/commentService.ts b/src/vs/workbench/contrib/comments/browser/commentService.ts index 4823e3aec3a..d141a1058b8 100644 --- a/src/vs/workbench/contrib/comments/browser/commentService.ts +++ b/src/vs/workbench/contrib/comments/browser/commentService.ts @@ -48,6 +48,7 @@ export interface ICommentService { unregisterCommentController(owner: string): void; getCommentController(owner: string): MainThreadCommentController | undefined; createCommentThreadTemplate(owner: string, resource: URI, range: Range): void; + updateCommentThreadTemplate(owner: string, threadHandle: number, range: Range): Promise; getCommentMenus(owner: string): CommentMenus; registerDataProvider(owner: string, commentProvider: DocumentCommentProvider): void; unregisterDataProvider(owner: string): void; @@ -145,6 +146,16 @@ export class CommentService extends Disposable implements ICommentService { commentController.createCommentThreadTemplate(resource, range); } + async updateCommentThreadTemplate(owner: string, threadHandle: number, range: Range) { + const commentController = this._commentControls.get(owner); + + if (!commentController) { + return; + } + + await commentController.updateCommentThreadTemplate(threadHandle, range); + } + disposeCommentThread(owner: string, threadId: string) { let controller = this.getCommentController(owner); if (controller) { diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts index 9d11f9114bf..0ecc5490c94 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts @@ -763,7 +763,14 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget this._commentFormActions.setActions(menu); })); - this._commentFormActions = new CommentFormActions(container, (action: IAction) => { + this._commentFormActions = new CommentFormActions(container, async (action: IAction) => { + if (!commentThread.comments || !commentThread.comments.length) { + let newPosition = this.getPosition(); + + if (newPosition) { + this.commentService.updateCommentThreadTemplate(this.owner, commentThread.commentThreadHandle, new Range(newPosition.lineNumber, 1, newPosition.lineNumber, 1)); + } + } action.run({ thread: this._commentThread, text: this._commentEditor.getValue(), @@ -965,6 +972,13 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget const frameThickness = Math.round(lineHeight / 9) * 2; const computedLinesNumber = Math.ceil((headHeight + dimensions.height + arrowHeight + frameThickness + 8 /** margin bottom to avoid margin collapse */) / lineHeight); + + let currentPosition = this.getPosition(); + + if (this._viewZone && currentPosition && currentPosition.lineNumber !== this._viewZone.afterLineNumber) { + this._viewZone.afterLineNumber = currentPosition.lineNumber; + } + this._relayout(computedLinesNumber); } } diff --git a/src/vs/workbench/contrib/comments/browser/media/review.css b/src/vs/workbench/contrib/comments/browser/media/review.css index 4ed2c4be005..5d147efe7ac 100644 --- a/src/vs/workbench/contrib/comments/browser/media/review.css +++ b/src/vs/workbench/contrib/comments/browser/media/review.css @@ -178,6 +178,7 @@ .monaco-editor .review-widget .body .review-comment .review-comment-contents .comment-reactions .action-item a.action-label.toolbar-toggle-pickReactions { display: none; background-image: url(./reaction.svg); + background-size: 24px; width: 26px; height: 16px; background-repeat: no-repeat; @@ -188,6 +189,7 @@ .monaco-editor .review-widget .body .review-comment .review-comment-contents .comment-reactions:hover .action-item a.action-label.toolbar-toggle-pickReactions { display: inline-block; + background-size: 24px; } .monaco-editor.vs-dark .review-widget .body .review-comment .review-comment-contents .comment-reactions .action-item a.action-label.toolbar-toggle-pickReactions { @@ -212,7 +214,7 @@ background-image: url(./reaction.svg); width: 18px; height: 18px; - background-size: 100% auto; + background-size: 24px; background-position: center; background-repeat: no-repeat; }