Skip to content

Commit c91649f

Browse files
authored
Comment widget doesn't work with inline diffs on deleted lines (microsoft#165547)
Fixes microsoft#164729
1 parent 6ef8bb8 commit c91649f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ import { commentThreadRangeActiveBackground, commentThreadRangeActiveBorder, com
5151
import { ICursorSelectionChangedEvent } from 'vs/editor/common/cursorEvents';
5252
import { CommentsPanel } from 'vs/workbench/contrib/comments/browser/commentsView';
5353
import { withNullAsUndefined, withUndefinedAsNull } from 'vs/base/common/types';
54+
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
55+
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
56+
import { URI } from 'vs/base/common/uri';
5457

5558
export const ID = 'editor.contrib.review';
5659

@@ -345,7 +348,8 @@ export class CommentController implements IEditorContribution {
345348
@IQuickInputService private readonly quickInputService: IQuickInputService,
346349
@IViewsService private readonly viewsService: IViewsService,
347350
@IConfigurationService private readonly configurationService: IConfigurationService,
348-
@IContextKeyService readonly contextKeyService: IContextKeyService
351+
@IContextKeyService readonly contextKeyService: IContextKeyService,
352+
@IEditorService private readonly editorService: IEditorService
349353
) {
350354
this._commentInfos = [];
351355
this._commentWidgets = [];
@@ -458,6 +462,13 @@ export class CommentController implements IEditorContribution {
458462
this._activeCursorHasCommentingRange.set(hasCommentingRange);
459463
}
460464

465+
private isEditorInlineOriginal(editorURI: URI | undefined, activeEditor: EditorInput | undefined): activeEditor is DiffEditorInput {
466+
if (editorURI && activeEditor instanceof DiffEditorInput && !this.configurationService.getValue('diffEditor.renderSideBySide')) {
467+
return activeEditor.original.resource?.toString() === editorURI.toString();
468+
}
469+
return false;
470+
}
471+
461472
private beginCompute(): Promise<void> {
462473
this._computePromise = createCancelablePromise(token => {
463474
const editorURI = this.editor && this.editor.hasModel() && this.editor.getModel().uri;
@@ -723,6 +734,10 @@ export class CommentController implements IEditorContribution {
723734
if (!this.editor) {
724735
return;
725736
}
737+
const activeEditor = this.editorService.activeEditor;
738+
if (this.isEditorInlineOriginal(this.editor.getModel()?.uri, activeEditor)) {
739+
return;
740+
}
726741
const zoneWidget = this.instantiationService.createInstance(ReviewZoneWidget, this.editor, owner, thread, pendingComment);
727742
zoneWidget.display(thread.range.endLineNumber);
728743
this._commentWidgets.push(zoneWidget);

0 commit comments

Comments
 (0)