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

Comment widget doesn't work with inline diffs on deleted lines #165547

Merged
merged 1 commit into from Nov 4, 2022
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
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