Do not truncate the range
This commit is contained in:
parent
3b61acb4ae
commit
770bb8dc9b
1 changed files with 10 additions and 30 deletions
|
@ -83,20 +83,14 @@ export class HintsUpdater {
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const newHints = await this.queryHints(editor.document.uri.toString());
|
const newHints = await this.queryHints(editor.document.uri.toString());
|
||||||
if (newHints !== null) {
|
if (newHints !== null) {
|
||||||
const newDecorations = newHints.map(hint => {
|
const newDecorations = newHints.map(hint => ({
|
||||||
const [label, range] = this.truncateHint(
|
range: hint.range,
|
||||||
hint.label,
|
renderOptions: {
|
||||||
hint.range
|
after: {
|
||||||
);
|
contentText: `: ${this.truncateHint(hint.label)}`
|
||||||
return {
|
|
||||||
range,
|
|
||||||
renderOptions: {
|
|
||||||
after: {
|
|
||||||
contentText: `: ${label}`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
});
|
}));
|
||||||
return editor.setDecorations(
|
return editor.setDecorations(
|
||||||
typeHintDecorationType,
|
typeHintDecorationType,
|
||||||
newDecorations
|
newDecorations
|
||||||
|
@ -104,30 +98,16 @@ export class HintsUpdater {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private truncateHint(
|
private truncateHint(label: string): string {
|
||||||
label: string,
|
|
||||||
range: vscode.Range
|
|
||||||
): [string, vscode.Range] {
|
|
||||||
if (!Server.config.maxInlayHintLength) {
|
if (!Server.config.maxInlayHintLength) {
|
||||||
return [label, range];
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
let newLabel = label.substring(0, Server.config.maxInlayHintLength);
|
let newLabel = label.substring(0, Server.config.maxInlayHintLength);
|
||||||
if (label.length > Server.config.maxInlayHintLength) {
|
if (label.length > Server.config.maxInlayHintLength) {
|
||||||
newLabel += '…';
|
newLabel += '…';
|
||||||
}
|
}
|
||||||
|
return newLabel;
|
||||||
range = new vscode.Range(
|
|
||||||
range.start.line,
|
|
||||||
range.start.character,
|
|
||||||
range.end.line,
|
|
||||||
Math.min(
|
|
||||||
range.start.character + Server.config.maxInlayHintLength,
|
|
||||||
range.end.character
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return [newLabel, range];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async queryHints(documentUri: string): Promise<InlayHint[] | null> {
|
private async queryHints(documentUri: string): Promise<InlayHint[] | null> {
|
||||||
|
|
Loading…
Reference in a new issue