Refresh master with initial release/0.24 snapshot (#332)

* Initial port of release/0.24 source code

* Fix additional headers

* Fix a typo in launch.json
This commit is contained in:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -7,7 +7,6 @@
import * as nativeKeymap from 'native-keymap';
import { IDisposable } from 'vs/base/common/lifecycle';
import { isMacintosh } from 'vs/base/common/platform';
import { IStorageService } from 'vs/platform/storage/node/storage';
import Event, { Emitter, once } from 'vs/base/common/event';
import { ConfigWatcher } from 'vs/base/node/config';
@@ -21,59 +20,24 @@ export class KeyboardLayoutMonitor {
public static readonly INSTANCE = new KeyboardLayoutMonitor();
private _emitter: Emitter<boolean>;
private _emitter: Emitter<void>;
private _registered: boolean;
private _isISOKeyboard: boolean;
private constructor() {
this._emitter = new Emitter<boolean>();
this._emitter = new Emitter<void>();
this._registered = false;
this._isISOKeyboard = this._readIsISOKeyboard();
}
public onDidChangeKeyboardLayout(callback: (isISOKeyboard: boolean) => void): IDisposable {
public onDidChangeKeyboardLayout(callback: () => void): IDisposable {
if (!this._registered) {
this._registered = true;
nativeKeymap.onDidChangeKeyboardLayout(() => {
this._emitter.fire(this._isISOKeyboard);
this._emitter.fire();
});
if (isMacintosh) {
// See https://github.com/Microsoft/vscode/issues/24153
// On OSX, on ISO keyboards, Chromium swaps the scan codes
// of IntlBackslash and Backquote.
//
// The C++ methods can give the current keyboard type (ISO or not)
// only after a NSEvent was handled.
//
// We therefore poll.
setInterval(() => {
let newValue = this._readIsISOKeyboard();
if (this._isISOKeyboard === newValue) {
// no change
return;
}
this._isISOKeyboard = newValue;
this._emitter.fire(this._isISOKeyboard);
}, 3000);
}
}
return this._emitter.event(callback);
}
private _readIsISOKeyboard(): boolean {
if (isMacintosh) {
return nativeKeymap.isISOKeyboard();
}
return false;
}
public isISOKeyboard(): boolean {
return this._isISOKeyboard;
}
}
export interface IKeybinding {
@@ -157,7 +121,7 @@ export class KeybindingsResolver {
private resolveKeybindings(win = this.windowsService.getLastActiveWindow()): void {
if (this.commandIds.size && win) {
const commandIds = [];
const commandIds: string[] = [];
this.commandIds.forEach(id => commandIds.push(id));
win.sendWhenReady('vscode:resolveKeybindings', JSON.stringify(commandIds));
}
@@ -174,4 +138,9 @@ export class KeybindingsResolver {
return this.keybindings[commandId];
}
public dispose(): void {
this._onKeybindingsChanged.dispose();
this.keybindingsWatcher.dispose();
}
}