Allow ignoring the keymap mismatch
This commit is contained in:
parent
3abbf8d01a
commit
8508bb8b77
|
@ -29,6 +29,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
|||
import { INavigatorWithKeyboard } from 'vs/workbench/services/keybinding/common/navigatorKeyboard';
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { StorageScope, IStorageService } from 'vs/platform/storage/common/storage';
|
||||
|
||||
export class BrowserKeyboardMapperFactoryBase {
|
||||
// keyboard mapper
|
||||
|
@ -72,6 +73,7 @@ export class BrowserKeyboardMapperFactoryBase {
|
|||
|
||||
protected constructor(
|
||||
private _notificationService: INotificationService,
|
||||
private _storageService: IStorageService,
|
||||
private _commandService: ICommandService
|
||||
) {
|
||||
this._keyboardMapper = null;
|
||||
|
@ -180,6 +182,11 @@ export class BrowserKeyboardMapperFactoryBase {
|
|||
let score = matchedKeyboardLayout.score;
|
||||
|
||||
if (keymap && score < 0) {
|
||||
const donotAskUpdateKey = 'missing.keyboardlayout.donotask';
|
||||
if (this._storageService.getBoolean(donotAskUpdateKey, StorageScope.GLOBAL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// the keyboard layout doesn't actually match the key event or the keymap from chromium
|
||||
this._notificationService.prompt(
|
||||
Severity.Info,
|
||||
|
@ -187,7 +194,11 @@ export class BrowserKeyboardMapperFactoryBase {
|
|||
[{
|
||||
label: nls.localize('keyboardLayoutMissing.configure', "Configure"),
|
||||
run: () => this._commandService.executeCommand('workbench.action.openKeyboardLayoutPicker')
|
||||
}],
|
||||
}, {
|
||||
label: nls.localize('neverAgain', "Don't Show Again"),
|
||||
isSecondary: true,
|
||||
run: () => this._storageService.store(donotAskUpdateKey, true, StorageScope.GLOBAL)
|
||||
}]
|
||||
);
|
||||
|
||||
return;
|
||||
|
@ -413,8 +424,8 @@ export class BrowserKeyboardMapperFactoryBase {
|
|||
}
|
||||
|
||||
export class BrowserKeyboardMapperFactory extends BrowserKeyboardMapperFactoryBase {
|
||||
constructor(notificationService: INotificationService, commandService: ICommandService) {
|
||||
super(notificationService, commandService);
|
||||
constructor(notificationService: INotificationService, storageService: IStorageService, commandService: ICommandService) {
|
||||
super(notificationService, storageService, commandService);
|
||||
|
||||
const platform = isWindows ? 'win' : isMacintosh ? 'darwin' : 'linux';
|
||||
|
||||
|
@ -549,13 +560,14 @@ class BrowserKeymapService extends Disposable implements IKeymapService {
|
|||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
@IFileService fileService: IFileService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@ICommandService commandService: ICommandService,
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
) {
|
||||
super();
|
||||
const keyboardConfig = configurationService.getValue<{ layout: string }>('keyboard');
|
||||
const layout = keyboardConfig.layout;
|
||||
this._factory = new BrowserKeyboardMapperFactory(notificationService, commandService);
|
||||
this._factory = new BrowserKeyboardMapperFactory(notificationService, storageService, commandService);
|
||||
|
||||
this.registerKeyboardListener();
|
||||
|
||||
|
|
|
@ -11,10 +11,11 @@ import { KeymapInfo, IKeymapInfo } from '../common/keymapInfo';
|
|||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
|
||||
class TestKeyboardMapperFactory extends BrowserKeyboardMapperFactoryBase {
|
||||
constructor(notificationService: INotificationService, commandService: ICommandService) {
|
||||
super(notificationService, commandService);
|
||||
constructor(notificationService: INotificationService, storageService: IStorageService, commandService: ICommandService) {
|
||||
super(notificationService, storageService, commandService);
|
||||
|
||||
let keymapInfos: IKeymapInfo[] = KeyboardLayoutContribution.INSTANCE.layoutInfos;
|
||||
this._keymapInfos.push(...keymapInfos.map(info => (new KeymapInfo(info.layout, info.secondaryLayouts, info.mapping, info.isUserKeyboardLayout))));
|
||||
|
@ -28,8 +29,9 @@ class TestKeyboardMapperFactory extends BrowserKeyboardMapperFactoryBase {
|
|||
suite('keyboard layout loader', () => {
|
||||
let instantiationService: TestInstantiationService = new TestInstantiationService();
|
||||
let notitifcationService = instantiationService.stub(INotificationService, {});
|
||||
let storageService = instantiationService.stub(IStorageService, {});
|
||||
let commandService = instantiationService.stub(ICommandService, {});
|
||||
let instance = new TestKeyboardMapperFactory(notitifcationService, commandService);
|
||||
let instance = new TestKeyboardMapperFactory(notitifcationService, storageService, commandService);
|
||||
|
||||
test.skip('load default US keyboard layout', () => {
|
||||
assert.notEqual(instance.activeKeyboardLayout, null);
|
||||
|
|
Loading…
Reference in a new issue