mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user