Skip to content

Commit 73743b9

Browse files
author
Hermann Loose
committed
Apply themable colors for resolved and unresolved comments
1 parent 6ff5252 commit 73743b9

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

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

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { IMenu, MenuItemAction, SubmenuItemAction } from 'vs/platform/actions/co
2929
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
3030
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
3131
import { IOpenerService } from 'vs/platform/opener/common/opener';
32-
import { contrastBorder, editorForeground, focusBorder, inputValidationErrorBackground, inputValidationErrorBorder, inputValidationErrorForeground, resolveColorValue, textBlockQuoteBackground, textBlockQuoteBorder, textLinkActiveForeground, textLinkForeground } from 'vs/platform/theme/common/colorRegistry';
32+
import { contrastBorder, editorForeground, registerColor, focusBorder, inputValidationErrorBackground, inputValidationErrorBorder, inputValidationErrorForeground, resolveColorValue, textBlockQuoteBackground, textBlockQuoteBorder, textLinkActiveForeground, textLinkForeground } from 'vs/platform/theme/common/colorRegistry';
3333
import { IColorTheme, IThemeService, ThemeIcon } from 'vs/platform/theme/common/themeService';
3434
import { CommentFormActions } from 'vs/workbench/contrib/comments/browser/commentFormActions';
3535
import { CommentGlyphWidget } from 'vs/workbench/contrib/comments/browser/commentGlyphWidget';
@@ -57,6 +57,21 @@ const COLLAPSE_ACTION_CLASS = 'expand-review-action ' + ThemeIcon.asClassName(co
5757
const COMMENT_SCHEME = 'comment';
5858

5959

60+
export const resolvedCommentBorder = registerColor('resolvedComment.border', { dark: Color.fromHex('#c5c5c5'), light: Color.fromHex('#555'), hc: contrastBorder }, nls.localize('resolvedCommentBorder', 'Color of borders and arrow for resolved comments.'));
61+
export const unresolvedCommentBorder = registerColor('unresolvedComment.border', { dark: Color.fromHex('#f4cd5d'), light: Color.fromHex('#ff0'), hc: contrastBorder }, nls.localize('unresolvedCommentBorder', 'Color of borders and arrow for unresolved comments.'));
62+
63+
const commentThreadStateColors = new Map([
64+
[languages.CommentThreadState.Unresolved, unresolvedCommentBorder],
65+
[languages.CommentThreadState.Resolved, resolvedCommentBorder],
66+
]);
67+
68+
const commentThreadStateColorVar = '--comment-thread-state-color';
69+
70+
function getCommentThreadStateColor(thread: languages.CommentThread, theme: IColorTheme): Color | undefined {
71+
const colorId = thread.state !== undefined ? commentThreadStateColors.get(thread.state) : undefined;
72+
return colorId !== undefined ? theme.getColor(colorId) : undefined;
73+
}
74+
6075
export function parseMouseDownInfoFromEvent(e: IEditorMouseEvent) {
6176
const range = e.target.range;
6277

@@ -639,8 +654,14 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
639654
await this.update(this._commentThread);
640655
}));
641656

642-
this._commentThreadDisposables.push(this._commentThread.onDidChangeState(async _ => {
643-
await this.update(this._commentThread);
657+
this._commentThreadDisposables.push(this._commentThread.onDidChangeState(() => {
658+
const borderColor =
659+
getCommentThreadStateColor(this._commentThread, this.themeService.getColorTheme()) || Color.transparent;
660+
this.style({
661+
frameColor: borderColor,
662+
arrowColor: borderColor,
663+
});
664+
this.container?.style.setProperty(commentThreadStateColorVar, `${borderColor}`);
644665
}));
645666

646667
this._commentThreadDisposables.push(this._commentThread.onDidChangeLabel(_ => {
@@ -894,17 +915,16 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
894915
}
895916

896917
private _applyTheme(theme: IColorTheme) {
897-
const borderColor = Color.fromHex('#ff0000') || theme.getColor(peekViewBorder);
918+
const borderColor = getCommentThreadStateColor(this._commentThread, theme) || Color.transparent;
898919
this.style({
899-
arrowColor: borderColor || Color.transparent,
900-
frameColor: borderColor || Color.transparent
920+
arrowColor: borderColor,
921+
frameColor: borderColor,
901922
});
902923

903924
const content: string[] = [];
904925

905-
if (borderColor) {
906-
content.push(`.monaco-editor .review-widget > .body { border-top: 1px solid ${borderColor} }`);
907-
}
926+
this.container?.style.setProperty(commentThreadStateColorVar, `${borderColor}`);
927+
content.push(`.monaco-editor .review-widget > .body { border-top: 1px solid var(${commentThreadStateColorVar}) }`);
908928

909929
const linkColor = theme.getColor(textLinkForeground);
910930
if (linkColor) {

0 commit comments

Comments
 (0)