Skip to content

Commit

Permalink
Aria status when editor has commenting ranges
Browse files Browse the repository at this point in the history
Part of #192377
  • Loading branch information
alexr00 committed Sep 15, 2023
1 parent bc6b75e commit c7fd3a4
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/vs/workbench/contrib/comments/browser/commentsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { Position } from 'vs/editor/common/core/position';
import { CommentThreadRangeDecorator } from 'vs/workbench/contrib/comments/browser/commentThreadRangeDecorator';
import { ICursorSelectionChangedEvent } from 'vs/editor/common/cursorEvents';
import { CommentsPanel } from 'vs/workbench/contrib/comments/browser/commentsView';
import { status } from 'vs/base/browser/ui/aria/aria';

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

Expand Down Expand Up @@ -330,6 +331,7 @@ export class CommentController implements IEditorContribution {
private _pendingEditsCache: { [key: string]: { [key: string]: { [key: number]: string } } }; // owner -> threadId -> uniqueIdInThread -> pending comment
private _editorDisposables: IDisposable[] = [];
private _activeCursorHasCommentingRange: IContextKey<boolean>;
private _hasProvidedAriaStatus: boolean = false;

constructor(
editor: ICodeEditor,
Expand Down Expand Up @@ -377,8 +379,8 @@ export class CommentController implements IEditorContribution {
}
this.beginCompute();
}));
this.globalToDispose.add(this.commentService.onDidSetDataProvider(_ => this.beginCompute()));
this.globalToDispose.add(this.commentService.onDidUpdateCommentingRanges(_ => this.beginCompute()));
this.globalToDispose.add(this.commentService.onDidSetDataProvider(_ => this.beginComputeAndProvideStatus()));
this.globalToDispose.add(this.commentService.onDidUpdateCommentingRanges(_ => this.beginComputeAndProvideStatus()));

this.globalToDispose.add(this.commentService.onDidSetResourceCommentInfos(e => {
const editorURI = this.editor && this.editor.hasModel() && this.editor.getModel().uri;
Expand Down Expand Up @@ -686,6 +688,8 @@ export class CommentController implements IEditorContribution {
return;
}

this._hasProvidedAriaStatus = false;

this.localToDispose.add(this.editor.onMouseDown(e => this.onEditorMouseDown(e)));
this.localToDispose.add(this.editor.onMouseUp(e => this.onEditorMouseUp(e)));
if (this._editorDisposables.length) {
Expand Down Expand Up @@ -775,7 +779,16 @@ export class CommentController implements IEditorContribution {
this._commentThreadRangeDecorator.update(this.editor, commentInfo);
}));

this.beginCompute();
this.beginComputeAndProvideStatus();
}

private beginComputeAndProvideStatus(): void {
this.beginCompute().then(() => {
if (!this._hasProvidedAriaStatus && this._commentInfos.some(commentInfo => commentInfo.commentingRanges.ranges.length > 0 || commentInfo.commentingRanges.fileComments)) {
this._hasProvidedAriaStatus = true;
status(nls.localize('hasCommentRanges', "Editor has commenting ranges."));
}
});
}

private async openCommentsView(thread: languages.CommentThread) {
Expand Down

0 comments on commit c7fd3a4

Please sign in to comment.