@@ -10,7 +10,11 @@ export function activateInlayHints(ctx: Ctx) {
10
10
const maybeUpdater = {
11
11
updater : null as null | HintsUpdater ,
12
12
onConfigChange ( ) {
13
- if ( ! ctx . config . inlayHints . typeHints && ! ctx . config . inlayHints . parameterHints ) {
13
+ if (
14
+ ! ctx . config . inlayHints . typeHints &&
15
+ ! ctx . config . inlayHints . parameterHints &&
16
+ ! ctx . config . inlayHints . chainingHints
17
+ ) {
14
18
return this . dispose ( ) ;
15
19
}
16
20
if ( ! this . updater ) this . updater = new HintsUpdater ( ctx ) ;
@@ -63,6 +67,22 @@ const paramHints = {
63
67
}
64
68
} ;
65
69
70
+ const chainingHints = {
71
+ decorationType : vscode . window . createTextEditorDecorationType ( {
72
+ after : {
73
+ color : new vscode . ThemeColor ( 'rust_analyzer.inlayHint' ) ,
74
+ fontStyle : "normal" ,
75
+ }
76
+ } ) ,
77
+
78
+ toDecoration ( hint : ra . InlayHint . ChainingHint , conv : lc . Protocol2CodeConverter ) : vscode . DecorationOptions {
79
+ return {
80
+ range : conv . asRange ( hint . range ) ,
81
+ renderOptions : { after : { contentText : ` ${ hint . label } ` } }
82
+ } ;
83
+ }
84
+ } ;
85
+
66
86
class HintsUpdater implements Disposable {
67
87
private sourceFiles = new Map < string , RustSourceFile > ( ) ; // map Uri -> RustSourceFile
68
88
private readonly disposables : Disposable [ ] = [ ] ;
@@ -95,7 +115,7 @@ class HintsUpdater implements Disposable {
95
115
96
116
dispose ( ) {
97
117
this . sourceFiles . forEach ( file => file . inlaysRequest ?. cancel ( ) ) ;
98
- this . ctx . visibleRustEditors . forEach ( editor => this . renderDecorations ( editor , { param : [ ] , type : [ ] } ) ) ;
118
+ this . ctx . visibleRustEditors . forEach ( editor => this . renderDecorations ( editor , { param : [ ] , type : [ ] , chaining : [ ] } ) ) ;
99
119
this . disposables . forEach ( d => d . dispose ( ) ) ;
100
120
}
101
121
@@ -154,10 +174,11 @@ class HintsUpdater implements Disposable {
154
174
private renderDecorations ( editor : RustEditor , decorations : InlaysDecorations ) {
155
175
editor . setDecorations ( typeHints . decorationType , decorations . type ) ;
156
176
editor . setDecorations ( paramHints . decorationType , decorations . param ) ;
177
+ editor . setDecorations ( chainingHints . decorationType , decorations . chaining ) ;
157
178
}
158
179
159
180
private hintsToDecorations ( hints : ra . InlayHint [ ] ) : InlaysDecorations {
160
- const decorations : InlaysDecorations = { type : [ ] , param : [ ] } ;
181
+ const decorations : InlaysDecorations = { type : [ ] , param : [ ] , chaining : [ ] } ;
161
182
const conv = this . ctx . client . protocol2CodeConverter ;
162
183
163
184
for ( const hint of hints ) {
@@ -170,6 +191,10 @@ class HintsUpdater implements Disposable {
170
191
decorations . param . push ( paramHints . toDecoration ( hint , conv ) ) ;
171
192
continue ;
172
193
}
194
+ case ra . InlayHint . Kind . ChainingHint : {
195
+ decorations . chaining . push ( chainingHints . toDecoration ( hint , conv ) ) ;
196
+ continue ;
197
+ }
173
198
}
174
199
}
175
200
return decorations ;
@@ -196,6 +221,7 @@ class HintsUpdater implements Disposable {
196
221
interface InlaysDecorations {
197
222
type : vscode . DecorationOptions [ ] ;
198
223
param : vscode . DecorationOptions [ ] ;
224
+ chaining : vscode . DecorationOptions [ ] ;
199
225
}
200
226
201
227
interface RustSourceFile {
0 commit comments