mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
drop and warn when inlay hint has empty label, https://github.com/microsoft/vscode/issues/16221
This commit is contained in:
@@ -1198,7 +1198,9 @@ class InlayHintsAdapter {
|
||||
this._disposables.set(pid, new DisposableStore());
|
||||
const result: extHostProtocol.IInlayHintsDto = { hints: [], cacheId: pid };
|
||||
for (let i = 0; i < hints.length; i++) {
|
||||
result.hints.push(this._convertInlayHint(hints[i], [pid, i]));
|
||||
if (this._isValidInlayHint(hints[i])) {
|
||||
result.hints.push(this._convertInlayHint(hints[i], [pid, i]));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1218,6 +1220,9 @@ class InlayHintsAdapter {
|
||||
if (token.isCancellationRequested) {
|
||||
return undefined;
|
||||
}
|
||||
if (!this._isValidInlayHint(hint)) {
|
||||
return undefined;
|
||||
}
|
||||
return this._convertInlayHint(hint, id);
|
||||
}
|
||||
|
||||
@@ -1227,6 +1232,14 @@ class InlayHintsAdapter {
|
||||
this._cache.delete(id);
|
||||
}
|
||||
|
||||
private _isValidInlayHint(hint: vscode.InlayHint): boolean {
|
||||
if (hint.label.length === 0 || Array.isArray(hint.label) && hint.label.every(part => part.label.length === 0)) {
|
||||
console.log('INVALID inlay hint, empty label', hint);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private _convertInlayHint(hint: vscode.InlayHint, id: extHostProtocol.ChainedCacheId): extHostProtocol.IInlayHintDto {
|
||||
|
||||
const disposables = this._disposables.get(id[0]);
|
||||
|
||||
Reference in New Issue
Block a user