mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-22 11:24:24 +00:00
Merge pull request #2297 from kiljacken/master
Add fancy truncation of type hints.
This commit is contained in:
commit
eec68e6f45
10 changed files with 134 additions and 35 deletions
|
@ -87,7 +87,7 @@ export class HintsUpdater {
|
|||
range: hint.range,
|
||||
renderOptions: {
|
||||
after: {
|
||||
contentText: `: ${this.truncateHint(hint.label)}`
|
||||
contentText: `: ${hint.label}`
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
@ -98,18 +98,6 @@ export class HintsUpdater {
|
|||
}
|
||||
}
|
||||
|
||||
private truncateHint(label: string): string {
|
||||
if (!Server.config.maxInlayHintLength) {
|
||||
return label;
|
||||
}
|
||||
|
||||
let newLabel = label.substring(0, Server.config.maxInlayHintLength);
|
||||
if (label.length > Server.config.maxInlayHintLength) {
|
||||
newLabel += '…';
|
||||
}
|
||||
return newLabel;
|
||||
}
|
||||
|
||||
private async queryHints(documentUri: string): Promise<InlayHint[] | null> {
|
||||
const request: InlayHintsParams = {
|
||||
textDocument: { uri: documentUri }
|
||||
|
|
|
@ -43,6 +43,7 @@ export class Server {
|
|||
initializationOptions: {
|
||||
publishDecorations: true,
|
||||
lruCapacity: Server.config.lruCapacity,
|
||||
maxInlayHintLength: Server.config.maxInlayHintLength,
|
||||
excludeGlobs: Server.config.excludeGlobs,
|
||||
useClientWatching: Server.config.useClientWatching,
|
||||
featureFlags: Server.config.featureFlags
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue