From 5d1e90a63df03f9c1e27ec2bf900945baa2911a4 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Fri, 4 Nov 2022 15:19:12 -0400 Subject: [PATCH] Comment widget doesn't work with inline diffs on deleted lines Fixes #164729 --- .../browser/commentsEditorContribution.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index af59bb1d79cc7..da5c81f2b6285 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -51,6 +51,9 @@ import { commentThreadRangeActiveBackground, commentThreadRangeActiveBorder, com import { ICursorSelectionChangedEvent } from 'vs/editor/common/cursorEvents'; import { CommentsPanel } from 'vs/workbench/contrib/comments/browser/commentsView'; import { withNullAsUndefined, withUndefinedAsNull } from 'vs/base/common/types'; +import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; +import { EditorInput } from 'vs/workbench/common/editor/editorInput'; +import { URI } from 'vs/base/common/uri'; export const ID = 'editor.contrib.review'; @@ -345,7 +348,8 @@ export class CommentController implements IEditorContribution { @IQuickInputService private readonly quickInputService: IQuickInputService, @IViewsService private readonly viewsService: IViewsService, @IConfigurationService private readonly configurationService: IConfigurationService, - @IContextKeyService readonly contextKeyService: IContextKeyService + @IContextKeyService readonly contextKeyService: IContextKeyService, + @IEditorService private readonly editorService: IEditorService ) { this._commentInfos = []; this._commentWidgets = []; @@ -458,6 +462,13 @@ export class CommentController implements IEditorContribution { this._activeCursorHasCommentingRange.set(hasCommentingRange); } + private isEditorInlineOriginal(editorURI: URI | undefined, activeEditor: EditorInput | undefined): activeEditor is DiffEditorInput { + if (editorURI && activeEditor instanceof DiffEditorInput && !this.configurationService.getValue('diffEditor.renderSideBySide')) { + return activeEditor.original.resource?.toString() === editorURI.toString(); + } + return false; + } + private beginCompute(): Promise { this._computePromise = createCancelablePromise(token => { const editorURI = this.editor && this.editor.hasModel() && this.editor.getModel().uri; @@ -723,6 +734,10 @@ export class CommentController implements IEditorContribution { if (!this.editor) { return; } + const activeEditor = this.editorService.activeEditor; + if (this.isEditorInlineOriginal(this.editor.getModel()?.uri, activeEditor)) { + return; + } const zoneWidget = this.instantiationService.createInstance(ReviewZoneWidget, this.editor, owner, thread, pendingComment); zoneWidget.display(thread.range.endLineNumber); this._commentWidgets.push(zoneWidget);