@@ -223,7 +223,7 @@ export class KeyboardLayoutProvider {
223223 public static readonly INSTANCE : KeyboardLayoutProvider = new KeyboardLayoutProvider ( ) ;
224224
225225 private _layoutInfos : KeyboardLayoutInfo [ ] = [ ] ;
226- // private _mru: KeyboardLayoutInfo[] = [];
226+ private _mru : KeyboardLayoutInfo [ ] = [ ] ;
227227 private _active : KeyboardLayoutInfo | null ;
228228
229229 private constructor ( ) {
@@ -232,6 +232,7 @@ export class KeyboardLayoutProvider {
232232
233233 registerKeyboardLayout ( layout : KeyboardLayoutInfo ) {
234234 this . _layoutInfos . push ( layout ) ;
235+ this . _mru = this . _layoutInfos ;
235236 }
236237
237238 get activeKeyboardLayout ( ) {
@@ -244,13 +245,25 @@ export class KeyboardLayoutProvider {
244245
245246 setActive ( keymap : IKeyboardMapping ) {
246247 this . _active = this . getMatchedKeyboardLayout ( keymap ) ;
248+
249+ if ( ! this . _active ) {
250+ return ;
251+ }
252+ const index = this . _mru . indexOf ( this . _active ) ;
253+
254+ if ( index === 0 ) {
255+ return ;
256+ }
257+
258+ this . _mru . splice ( index , 1 ) ;
259+ this . _mru . unshift ( this . _active ) ;
247260 }
248261
249262 getMatchedKeyboardLayout ( keymap : IKeyboardMapping ) : KeyboardLayoutInfo | null {
250263 // TODO go through mru list instead of _layoutInfos
251- for ( let i = 0 ; i < this . _layoutInfos . length ; i ++ ) {
252- if ( this . _layoutInfos [ i ] . fuzzyEqual ( keymap ) ) {
253- return this . _layoutInfos [ i ] ;
264+ for ( let i = 0 ; i < this . _mru . length ; i ++ ) {
265+ if ( this . _mru [ i ] . fuzzyEqual ( keymap ) ) {
266+ return this . _mru [ i ] ;
254267 }
255268 }
256269
0 commit comments