@@ -194,24 +194,23 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget {
194194 }
195195
196196 const code = dom . append ( this . domNodes . signature , $ ( '.code' ) ) ;
197- const hasParameters = signature . parameters . length > 0 ;
198-
199197 const fontInfo = this . editor . getOption ( EditorOption . fontInfo ) ;
200198 code . style . fontSize = `${ fontInfo . fontSize } px` ;
201199 code . style . fontFamily = fontInfo . fontFamily ;
202200
201+ const hasParameters = signature . parameters . length > 0 ;
202+ const activeParameterIndex = signature . activeParameter ?? hints . activeParameter ;
203+
203204 if ( ! hasParameters ) {
204205 const label = dom . append ( code , $ ( 'span' ) ) ;
205206 label . textContent = signature . label ;
206207 } else {
207- this . renderParameters ( code , signature , hints . activeParameter ) ;
208+ this . renderParameters ( code , signature , activeParameterIndex ) ;
208209 }
209210
210- this . renderDisposeables . clear ( ) ;
211-
212- const activeParameter : modes . ParameterInformation | undefined = signature . parameters [ hints . activeParameter ] ;
213211
214- if ( activeParameter && activeParameter . documentation ) {
212+ const activeParameter : modes . ParameterInformation | undefined = signature . parameters [ activeParameterIndex ] ;
213+ if ( activeParameter ?. documentation ) {
215214 const documentation = $ ( 'span.documentation' ) ;
216215 if ( typeof activeParameter . documentation === 'string' ) {
217216 documentation . textContent = activeParameter . documentation ;
@@ -243,7 +242,7 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget {
243242 pad ( hints . activeSignature + 1 , hints . signatures . length . toString ( ) . length ) + '/' + hints . signatures . length ;
244243
245244 if ( activeParameter ) {
246- const labelToAnnounce = this . getParameterLabel ( signature , hints . activeParameter ) ;
245+ const labelToAnnounce = this . getParameterLabel ( signature , activeParameterIndex ) ;
247246 // Select method gets called on every user type while parameter hints are visible.
248247 // We do not want to spam the user with same announcements, so we only announce if the current parameter changed.
249248
@@ -273,8 +272,8 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget {
273272 return false ;
274273 }
275274
276- private renderParameters ( parent : HTMLElement , signature : modes . SignatureInformation , currentParameter : number ) : void {
277- const [ start , end ] = this . getParameterLabelOffsets ( signature , currentParameter ) ;
275+ private renderParameters ( parent : HTMLElement , signature : modes . SignatureInformation , activeParameterIndex : number ) : void {
276+ const [ start , end ] = this . getParameterLabelOffsets ( signature , activeParameterIndex ) ;
278277
279278 const beforeSpan = document . createElement ( 'span' ) ;
280279 beforeSpan . textContent = signature . label . substring ( 0 , start ) ;
0 commit comments