提交 cc8c1758 编写于 作者: P Peng Lyu

switch to a new layout only when the score is higher.

上级 1e7b87a3
......@@ -154,7 +154,20 @@ export class BrowserKeyboardMapperFactoryBase {
}
setActiveKeyMapping(keymap: IKeyboardMapping | null) {
this._activeKeymapInfo = this.getMatchedKeymapInfo(keymap) || this.getUSStandardLayout();
let matchedKeyboardLayout = this.getMatchedKeymapInfo(keymap);
if (matchedKeyboardLayout) {
if (!this._activeKeymapInfo) {
this._activeKeymapInfo = matchedKeyboardLayout;
} else if (keymap) {
if (matchedKeyboardLayout.getScore(keymap) > this._activeKeymapInfo.getScore(keymap)) {
this._activeKeymapInfo = matchedKeyboardLayout;
}
}
}
if (!this._activeKeymapInfo) {
this._activeKeymapInfo = this.getUSStandardLayout();
}
if (!this._activeKeymapInfo) {
return;
......@@ -348,7 +361,7 @@ export class BrowserKeyboardMapperFactoryBase {
const matchedKeyboardLayout = this.getMatchedKeymapInfo(ret);
if (matchedKeyboardLayout) {
return matchedKeyboardLayout.mapping;
return ret;
}
return null;
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { Event } from 'vs/base/common/event';
import { isWindows } from 'vs/base/common/platform';
import { isWindows, isLinux } from 'vs/base/common/platform';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { DispatchConfig } from 'vs/workbench/services/keybinding/common/dispatchConfig';
import { IKeyboardMapper } from 'vs/workbench/services/keybinding/common/keyboardMapper';
......@@ -286,6 +286,12 @@ export class KeymapInfo {
// keymap from Chromium is probably wrong.
continue;
}
if (isLinux && (key === 'Backspace' || key === 'Escape')) {
// native keymap doesn't align with keyboard event
continue;
}
if (this.mapping[key] === undefined) {
score -= 1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册