mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 18:19:12 +01:00
Display outdated comments differently in the Comments view (#207410)
This commit is contained in:
@@ -265,6 +265,7 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
|
||||
canReply: boolean;
|
||||
state: vscode.CommentThreadState;
|
||||
isTemplate: boolean;
|
||||
applicability: vscode.CommentThreadApplicability;
|
||||
}>;
|
||||
|
||||
class ExtHostCommentThread implements vscode.CommentThread2 {
|
||||
@@ -368,15 +369,21 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
|
||||
this._onDidUpdateCommentThread.fire();
|
||||
}
|
||||
|
||||
private _state?: vscode.CommentThreadState;
|
||||
private _state?: vscode.CommentThreadState | { resolved?: vscode.CommentThreadState; applicability?: vscode.CommentThreadApplicability };
|
||||
|
||||
get state(): vscode.CommentThreadState {
|
||||
get state(): vscode.CommentThreadState | { resolved?: vscode.CommentThreadState; applicability?: vscode.CommentThreadApplicability } | undefined {
|
||||
return this._state!;
|
||||
}
|
||||
|
||||
set state(newState: vscode.CommentThreadState) {
|
||||
set state(newState: vscode.CommentThreadState | { resolved?: vscode.CommentThreadState; applicability?: vscode.CommentThreadApplicability }) {
|
||||
this._state = newState;
|
||||
this.modifications.state = newState;
|
||||
if (typeof newState === 'object') {
|
||||
checkProposedApiEnabled(this.extensionDescription, 'commentThreadApplicability');
|
||||
this.modifications.state = newState.resolved;
|
||||
this.modifications.applicability = newState.applicability;
|
||||
} else {
|
||||
this.modifications.state = newState;
|
||||
}
|
||||
this._onDidUpdateCommentThread.fire();
|
||||
}
|
||||
|
||||
@@ -454,8 +461,8 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
|
||||
set contextValue(value: string | undefined) { that.contextValue = value; },
|
||||
get label() { return that.label; },
|
||||
set label(value: string | undefined) { that.label = value; },
|
||||
get state() { return that.state; },
|
||||
set state(value: vscode.CommentThreadState) { that.state = value; },
|
||||
get state(): vscode.CommentThreadState | { resolved?: vscode.CommentThreadState; applicability?: vscode.CommentThreadApplicability } | undefined { return that.state; },
|
||||
set state(value: vscode.CommentThreadState | { resolved?: vscode.CommentThreadState; applicability?: vscode.CommentThreadApplicability }) { that.state = value; },
|
||||
dispose: () => {
|
||||
that.dispose();
|
||||
}
|
||||
@@ -510,6 +517,9 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
|
||||
if (modified('state')) {
|
||||
formattedModifications.state = convertToState(this._state);
|
||||
}
|
||||
if (modified('applicability')) {
|
||||
formattedModifications.applicability = convertToRelevance(this._state);
|
||||
}
|
||||
if (modified('isTemplate')) {
|
||||
formattedModifications.isTemplate = this._isTemplate;
|
||||
}
|
||||
@@ -766,9 +776,16 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
|
||||
return languages.CommentThreadCollapsibleState.Collapsed;
|
||||
}
|
||||
|
||||
function convertToState(kind: vscode.CommentThreadState | undefined): languages.CommentThreadState {
|
||||
if (kind !== undefined) {
|
||||
switch (kind) {
|
||||
function convertToState(kind: vscode.CommentThreadState | { resolved?: vscode.CommentThreadState; applicability?: vscode.CommentThreadApplicability } | undefined): languages.CommentThreadState {
|
||||
let resolvedKind: vscode.CommentThreadState | undefined;
|
||||
if (typeof kind === 'object') {
|
||||
resolvedKind = kind.resolved;
|
||||
} else {
|
||||
resolvedKind = kind;
|
||||
}
|
||||
|
||||
if (resolvedKind !== undefined) {
|
||||
switch (resolvedKind) {
|
||||
case types.CommentThreadState.Unresolved:
|
||||
return languages.CommentThreadState.Unresolved;
|
||||
case types.CommentThreadState.Resolved:
|
||||
@@ -778,5 +795,22 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
|
||||
return languages.CommentThreadState.Unresolved;
|
||||
}
|
||||
|
||||
function convertToRelevance(kind: vscode.CommentThreadState | { resolved?: vscode.CommentThreadState; applicability?: vscode.CommentThreadApplicability } | undefined): languages.CommentThreadApplicability {
|
||||
let applicabilityKind: vscode.CommentThreadApplicability | undefined = undefined;
|
||||
if (typeof kind === 'object') {
|
||||
applicabilityKind = kind.applicability;
|
||||
}
|
||||
|
||||
if (applicabilityKind !== undefined) {
|
||||
switch (applicabilityKind) {
|
||||
case types.CommentThreadApplicability.Current:
|
||||
return languages.CommentThreadApplicability.Current;
|
||||
case types.CommentThreadApplicability.Outdated:
|
||||
return languages.CommentThreadApplicability.Outdated;
|
||||
}
|
||||
}
|
||||
return languages.CommentThreadApplicability.Current;
|
||||
}
|
||||
|
||||
return new ExtHostCommentsImpl();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user