diff --git a/src/vs/editor/common/languages.ts b/src/vs/editor/common/languages.ts index 126f4bf63351c..79e1c5ce4b701 100644 --- a/src/vs/editor/common/languages.ts +++ b/src/vs/editor/common/languages.ts @@ -1716,7 +1716,7 @@ export interface Comment { readonly commentReactions?: CommentReaction[]; readonly label?: string; readonly mode?: CommentMode; - readonly detail?: Date | string; + readonly timestamp?: Date; } /** diff --git a/src/vs/workbench/api/browser/mainThreadComments.ts b/src/vs/workbench/api/browser/mainThreadComments.ts index d85214116b91f..6eec5fccee4ce 100644 --- a/src/vs/workbench/api/browser/mainThreadComments.ts +++ b/src/vs/workbench/api/browser/mainThreadComments.ts @@ -152,7 +152,7 @@ export class MainThreadCommentThread implements modes.CommentThread { userName: comment.userName, commentReactions: comment.commentReactions, contextValue: comment.contextValue, - detail: comment.detail ? revive(comment.detail) : undefined, + timestamp: comment.timestamp ? revive(comment.timestamp) : undefined, label: comment.label, mode: comment.mode, userIconPath: comment.userIconPath diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 624036b610041..f1060481b3fb2 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -169,9 +169,9 @@ export interface CommentChanges { readonly commentReactions?: modes.CommentReaction[]; readonly label?: string; readonly mode?: modes.CommentMode; - readonly detail?: { + readonly timestamp?: { $mid: MarshalledId.Date - } | string; + }; } export type CommentThreadChanges = Partial<{ diff --git a/src/vs/workbench/api/common/extHostComments.ts b/src/vs/workbench/api/common/extHostComments.ts index 915d28eb86633..fb020efd71e8b 100644 --- a/src/vs/workbench/api/common/extHostComments.ts +++ b/src/vs/workbench/api/common/extHostComments.ts @@ -618,18 +618,16 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo const iconPath = vscodeComment.author && vscodeComment.author.iconPath ? vscodeComment.author.iconPath.toString() : undefined; - if (vscodeComment.detail) { + if (vscodeComment.timestamp) { checkProposedApiEnabled(thread.extensionDescription, 'commentTimestamp'); } - let detail: { $mid: MarshalledId.Date, source: any } | string | undefined; - if (vscodeComment.detail && (typeof vscodeComment.detail !== 'string')) { - detail = { - source: vscodeComment.detail, + let timestamp: { $mid: MarshalledId.Date, source: any } | undefined; + if (vscodeComment.timestamp) { + timestamp = { + source: vscodeComment.timestamp, $mid: MarshalledId.Date }; - } else { - detail = vscodeComment.detail; } return { @@ -641,7 +639,7 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo userIconPath: iconPath, label: vscodeComment.label, commentReactions: vscodeComment.reactions ? vscodeComment.reactions.map(reaction => convertToReaction(reaction)) : undefined, - detail: detail + timestamp }; } diff --git a/src/vs/workbench/contrib/comments/browser/commentNode.ts b/src/vs/workbench/contrib/comments/browser/commentNode.ts index bae1f3ed23fbd..eecab0f8712fe 100644 --- a/src/vs/workbench/contrib/comments/browser/commentNode.ts +++ b/src/vs/workbench/contrib/comments/browser/commentNode.ts @@ -55,8 +55,8 @@ export class CommentNode extends Disposable { private _commentEditorDisposables: IDisposable[] = []; private _commentEditorModel: ITextModel | null = null; private _isPendingLabel!: HTMLElement; - private _detail: HTMLElement | undefined; - private _timestamp: TimestampWidget | undefined; + private _timestamp: HTMLElement | undefined; + private _timestampWidget: TimestampWidget | undefined; private _contextKeyService: IContextKeyService; private _commentContextValue: IContextKey; @@ -126,29 +126,24 @@ export class CommentNode extends Disposable { return this._onDidClick.event; } - private createDetail(container: HTMLElement) { - this._detail = dom.append(container, dom.$('span.detail')); - this.updateDetail(this.comment.detail); + private createTimestamp(container: HTMLElement) { + this._timestamp = dom.append(container, dom.$('span.timestamp-container')); + this.updateTimestamp(this.comment.timestamp); } - private updateDetail(detail?: Date | string) { - if (!this._detail) { + private updateTimestamp(timestamp?: Date) { + if (!this._timestamp) { return; } - if (!detail) { - this._timestamp?.dispose(); - this._detail.innerText = ''; - } else if (typeof detail === 'string') { - this._timestamp?.dispose(); - this._detail.innerText = detail; + if (!timestamp) { + this._timestampWidget?.dispose(); } else { - this._detail.innerText = ''; - if (!this._timestamp) { - this._timestamp = new TimestampWidget(this.configurationService, this._detail, detail); - this._register(this._timestamp); + if (!this._timestampWidget) { + this._timestampWidget = new TimestampWidget(this.configurationService, this._timestamp, timestamp); + this._register(this._timestampWidget); } else { - this._timestamp.setTimestamp(detail); + this._timestampWidget.setTimestamp(timestamp); } } } @@ -157,7 +152,7 @@ export class CommentNode extends Disposable { const header = dom.append(commentDetailsContainer, dom.$(`div.comment-title.${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME}`)); const author = dom.append(header, dom.$('strong.author')); author.innerText = this.comment.userName; - this.createDetail(header); + this.createTimestamp(header); this._isPendingLabel = dom.append(header, dom.$('span.isPending')); if (this.comment.label) { @@ -549,8 +544,8 @@ export class CommentNode extends Disposable { this._commentContextValue.reset(); } - if (this.comment.detail) { - this.updateDetail(this.comment.detail); + if (this.comment.timestamp) { + this.updateTimestamp(this.comment.timestamp); } } diff --git a/src/vscode-dts/vscode.proposed.commentTimestamp.d.ts b/src/vscode-dts/vscode.proposed.commentTimestamp.d.ts index 1039db61b9824..2867dcbfeabfc 100644 --- a/src/vscode-dts/vscode.proposed.commentTimestamp.d.ts +++ b/src/vscode-dts/vscode.proposed.commentTimestamp.d.ts @@ -6,10 +6,9 @@ declare module 'vscode' { export interface Comment { /** - * An optional detail that will be displayed less prominently than the `author`. - * If a date is provided, then the date will be formatted according to the user's - * locale and settings. + * An optional timestamp that will be displayed in comments. + * The date will be formatted according to the user's locale and settings. */ - detail?: Date | string + timestamp?: Date; } }