Skip to content

Commit 97702b8

Browse files
authored
comments view polish (microsoft#210507)
1 parent f90a94a commit 97702b8

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

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

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class CommentsPanel extends FilterViewPane implements ICommentsView {
8282
if (!this.focusedCommentNode) {
8383
return;
8484
}
85-
return this.getScreenReaderInfoForNode(this.focusedCommentNode, 'accessibleViewContent');
85+
return this.getScreenReaderInfoForNode(this.focusedCommentNode);
8686
}
8787

8888
focusNextNode(): void {
@@ -316,61 +316,70 @@ export class CommentsPanel extends FilterViewPane implements ICommentsView {
316316
this.messageBoxContainer.classList.toggle('hidden', this.commentService.commentsModel.hasCommentThreads());
317317
}
318318

319-
private getScreenReaderInfoForNode(element: CommentNode, type: 'ariaLabel' | 'accessibleViewContent') {
319+
private getScreenReaderInfoForNode(element: CommentNode, forAriaLabel?: boolean): string {
320320
let accessibleViewHint = '';
321-
if (type === 'ariaLabel' && this.configurationService.getValue(AccessibilityVerbositySettingId.Comments)) {
321+
if (forAriaLabel && this.configurationService.getValue(AccessibilityVerbositySettingId.Comments)) {
322322
const kbLabel = this.keybindingService.lookupKeybinding(AccessibleViewAction.id)?.getAriaLabel();
323323
accessibleViewHint = kbLabel ? nls.localize('acessibleViewHint', "Inspect this in the accessible view ({0}).\n", kbLabel) : nls.localize('acessibleViewHintNoKbOpen', "Inspect this in the accessible view via the command Open Accessible View which is currently not triggerable via keybinding.\n");
324324
}
325-
const replies = this.getRepliesAsString(element, type) || '';
325+
const replyCount = this.getReplyCountAsString(element, forAriaLabel);
326+
const replies = this.getRepliesAsString(element, forAriaLabel);
326327
if (element.range) {
327328
if (element.threadRelevance === CommentThreadApplicability.Outdated) {
328329
return accessibleViewHint + nls.localize('resourceWithCommentLabelOutdated',
329-
"Outdated from ${0} at line {1} column {2} in {3}, comment: {4}",
330+
"Outdated from {0} at line {1} column {2} in {3},{4} comment: {5}",
330331
element.comment.userName,
331332
element.range.startLineNumber,
332333
element.range.startColumn,
333334
basename(element.resource),
335+
replyCount,
334336
(typeof element.comment.body === 'string') ? element.comment.body : element.comment.body.value
335337
) + replies;
336338
} else {
337339
return accessibleViewHint + nls.localize('resourceWithCommentLabel',
338-
"${0} at line {1} column {2} in {3}, comment: {4}",
340+
"{0} at line {1} column {2} in {3},{4} comment: {5}",
339341
element.comment.userName,
340342
element.range.startLineNumber,
341343
element.range.startColumn,
342344
basename(element.resource),
345+
replyCount,
343346
(typeof element.comment.body === 'string') ? element.comment.body : element.comment.body.value,
344347
) + replies;
345348
}
346349
} else {
347350
if (element.threadRelevance === CommentThreadApplicability.Outdated) {
348351
return accessibleViewHint + nls.localize('resourceWithCommentLabelFileOutdated',
349-
"Outdated from {0} in {1}, comment: {2}",
352+
"Outdated from {0} in {1},{2} comment: {3}",
350353
element.comment.userName,
351354
basename(element.resource),
355+
replyCount,
352356
(typeof element.comment.body === 'string') ? element.comment.body : element.comment.body.value
353357
) + replies;
354358
} else {
355359
return accessibleViewHint + nls.localize('resourceWithCommentLabelFile',
356-
"{0} in {1}, comment: {2}",
360+
"{0} in {1},{2} comment: {3}",
357361
element.comment.userName,
358362
basename(element.resource),
363+
replyCount,
359364
(typeof element.comment.body === 'string') ? element.comment.body : element.comment.body.value
360365
) + replies;
361366
}
362367
}
363368
}
364369

365-
private getRepliesAsString(node: CommentNode, type: 'ariaLabel' | 'accessibleViewContent'): string {
366-
if (!node.replies.length || type === 'ariaLabel') {
370+
private getRepliesAsString(node: CommentNode, forAriaLabel?: boolean): string {
371+
if (!node.replies.length || forAriaLabel) {
367372
return '';
368373
}
369-
return nls.localize('replies', " {0} replies:\n{1}", node.replies.length, node.replies.map(reply => nls.localize('resourceWithRepliesLabel',
370-
"${0} {1}",
374+
return '\n' + node.replies.map(reply => nls.localize('resourceWithRepliesLabel',
375+
"{0} {1}",
371376
reply.comment.userName,
372377
(typeof reply.comment.body === 'string') ? reply.comment.body : reply.comment.body.value)
373-
).join('\n'));
378+
).join('\n');
379+
}
380+
381+
private getReplyCountAsString(node: CommentNode, forAriaLabel?: boolean): string {
382+
return node.replies.length && !forAriaLabel ? nls.localize('replyCount', " {0} replies,", node.replies.length) : '';
374383
}
375384

376385
private createTree(): void {
@@ -393,7 +402,7 @@ export class CommentsPanel extends FilterViewPane implements ICommentsView {
393402
return nls.localize('resourceWithCommentThreadsLabel', "Comments in {0}, full path {1}", basename(element.resource), element.resource.fsPath);
394403
}
395404
if (element instanceof CommentNode) {
396-
return this.getScreenReaderInfoForNode(element, 'ariaLabel');
405+
return this.getScreenReaderInfoForNode(element, true);
397406
}
398407
return '';
399408
},

0 commit comments

Comments
 (0)