Skip to content

Commit

Permalink
Comment widget doesn't work with inline diffs on deleted lines
Browse files Browse the repository at this point in the history
Fixes #164729
  • Loading branch information
alexr00 committed Nov 4, 2022
1 parent 5a8c62b commit 5d1e90a
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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<void> {
this._computePromise = createCancelablePromise(token => {
const editorURI = this.editor && this.editor.hasModel() && this.editor.getModel().uri;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5d1e90a

Please sign in to comment.