@@ -345,7 +345,7 @@ class TypeLabelController<T> implements IDisposable {
345345
346346 private automaticKeyboardNavigation = true ;
347347 private triggered = false ;
348- private charactersTyped = 0 ;
348+ private previouslyFocused = - 1 ;
349349
350350 private readonly enabledDisposables = new DisposableStore ( ) ;
351351 private readonly disposables = new DisposableStore ( ) ;
@@ -413,15 +413,15 @@ class TypeLabelController<T> implements IDisposable {
413413
414414 private onClear ( ) : void {
415415 const focus = this . list . getFocus ( ) ;
416- if ( focus . length > 0 && this . charactersTyped > 1 ) {
416+ if ( focus . length > 0 && focus [ 0 ] === this . previouslyFocused ) {
417417 // List: re-anounce element on typing end since typed keys will interupt aria label of focused element
418- // Do not announce if only one character typed to avoid duplicate announcment https://github.com/microsoft/vscode/issues/95961
418+ // Do not announce if there was a focus change at the end to prevent duplication https://github.com/microsoft/vscode/issues/95961
419419 const ariaLabel = this . list . options . accessibilityProvider ?. getAriaLabel ( this . list . element ( focus [ 0 ] ) ) ;
420420 if ( ariaLabel ) {
421421 alert ( ariaLabel ) ;
422422 }
423423 }
424- this . charactersTyped = 0 ;
424+ this . previouslyFocused = - 1 ;
425425 }
426426
427427 private onInput ( word : string | null ) : void {
@@ -431,7 +431,6 @@ class TypeLabelController<T> implements IDisposable {
431431 return ;
432432 }
433433
434- this . charactersTyped ++ ;
435434 const focus = this . list . getFocus ( ) ;
436435 const start = focus . length > 0 ? focus [ 0 ] : 0 ;
437436 const delta = this . state === TypeLabelControllerState . Idle ? 1 : 0 ;
@@ -443,6 +442,7 @@ class TypeLabelController<T> implements IDisposable {
443442 const labelStr = label && label . toString ( ) ;
444443
445444 if ( typeof labelStr === 'undefined' || matchesPrefix ( word , labelStr ) ) {
445+ this . previouslyFocused = start ;
446446 this . list . setFocus ( [ index ] ) ;
447447 this . list . reveal ( index ) ;
448448 return ;
0 commit comments