Skip to content

Commit 8508bb8

Browse files
committed
Allow ignoring the keymap mismatch
1 parent 3abbf8d commit 8508bb8

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

src/vs/workbench/services/keybinding/browser/keymapService.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
2929
import { INavigatorWithKeyboard } from 'vs/workbench/services/keybinding/common/navigatorKeyboard';
3030
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
3131
import { ICommandService } from 'vs/platform/commands/common/commands';
32+
import { StorageScope, IStorageService } from 'vs/platform/storage/common/storage';
3233

3334
export class BrowserKeyboardMapperFactoryBase {
3435
// keyboard mapper
@@ -72,6 +73,7 @@ export class BrowserKeyboardMapperFactoryBase {
7273

7374
protected constructor(
7475
private _notificationService: INotificationService,
76+
private _storageService: IStorageService,
7577
private _commandService: ICommandService
7678
) {
7779
this._keyboardMapper = null;
@@ -180,14 +182,23 @@ export class BrowserKeyboardMapperFactoryBase {
180182
let score = matchedKeyboardLayout.score;
181183

182184
if (keymap && score < 0) {
185+
const donotAskUpdateKey = 'missing.keyboardlayout.donotask';
186+
if (this._storageService.getBoolean(donotAskUpdateKey, StorageScope.GLOBAL)) {
187+
return;
188+
}
189+
183190
// the keyboard layout doesn't actually match the key event or the keymap from chromium
184191
this._notificationService.prompt(
185192
Severity.Info,
186193
nls.localize('missing.keyboardlayout', 'Fail to find matching keyboard layout'),
187194
[{
188195
label: nls.localize('keyboardLayoutMissing.configure', "Configure"),
189196
run: () => this._commandService.executeCommand('workbench.action.openKeyboardLayoutPicker')
190-
}],
197+
}, {
198+
label: nls.localize('neverAgain', "Don't Show Again"),
199+
isSecondary: true,
200+
run: () => this._storageService.store(donotAskUpdateKey, true, StorageScope.GLOBAL)
201+
}]
191202
);
192203

193204
return;
@@ -413,8 +424,8 @@ export class BrowserKeyboardMapperFactoryBase {
413424
}
414425

415426
export class BrowserKeyboardMapperFactory extends BrowserKeyboardMapperFactoryBase {
416-
constructor(notificationService: INotificationService, commandService: ICommandService) {
417-
super(notificationService, commandService);
427+
constructor(notificationService: INotificationService, storageService: IStorageService, commandService: ICommandService) {
428+
super(notificationService, storageService, commandService);
418429

419430
const platform = isWindows ? 'win' : isMacintosh ? 'darwin' : 'linux';
420431

@@ -549,13 +560,14 @@ class BrowserKeymapService extends Disposable implements IKeymapService {
549560
@IEnvironmentService environmentService: IEnvironmentService,
550561
@IFileService fileService: IFileService,
551562
@INotificationService notificationService: INotificationService,
563+
@IStorageService storageService: IStorageService,
552564
@ICommandService commandService: ICommandService,
553565
@IConfigurationService private configurationService: IConfigurationService,
554566
) {
555567
super();
556568
const keyboardConfig = configurationService.getValue<{ layout: string }>('keyboard');
557569
const layout = keyboardConfig.layout;
558-
this._factory = new BrowserKeyboardMapperFactory(notificationService, commandService);
570+
this._factory = new BrowserKeyboardMapperFactory(notificationService, storageService, commandService);
559571

560572
this.registerKeyboardListener();
561573

src/vs/workbench/services/keybinding/test/browserKeyboardMapper.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ import { KeymapInfo, IKeymapInfo } from '../common/keymapInfo';
1111
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
1212
import { INotificationService } from 'vs/platform/notification/common/notification';
1313
import { ICommandService } from 'vs/platform/commands/common/commands';
14+
import { IStorageService } from 'vs/platform/storage/common/storage';
1415

1516
class TestKeyboardMapperFactory extends BrowserKeyboardMapperFactoryBase {
16-
constructor(notificationService: INotificationService, commandService: ICommandService) {
17-
super(notificationService, commandService);
17+
constructor(notificationService: INotificationService, storageService: IStorageService, commandService: ICommandService) {
18+
super(notificationService, storageService, commandService);
1819

1920
let keymapInfos: IKeymapInfo[] = KeyboardLayoutContribution.INSTANCE.layoutInfos;
2021
this._keymapInfos.push(...keymapInfos.map(info => (new KeymapInfo(info.layout, info.secondaryLayouts, info.mapping, info.isUserKeyboardLayout))));
@@ -28,8 +29,9 @@ class TestKeyboardMapperFactory extends BrowserKeyboardMapperFactoryBase {
2829
suite('keyboard layout loader', () => {
2930
let instantiationService: TestInstantiationService = new TestInstantiationService();
3031
let notitifcationService = instantiationService.stub(INotificationService, {});
32+
let storageService = instantiationService.stub(IStorageService, {});
3133
let commandService = instantiationService.stub(ICommandService, {});
32-
let instance = new TestKeyboardMapperFactory(notitifcationService, commandService);
34+
let instance = new TestKeyboardMapperFactory(notitifcationService, storageService, commandService);
3335

3436
test.skip('load default US keyboard layout', () => {
3537
assert.notEqual(instance.activeKeyboardLayout, null);

0 commit comments

Comments
 (0)