UNPKG

sussudio

Version:

An unofficial VS Code Internal API

43 lines (42 loc) 1.74 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ export class ResolvedKeybindingItem { _resolvedKeybindingItemBrand = undefined; resolvedKeybinding; chords; bubble; command; commandArgs; when; isDefault; extensionId; isBuiltinExtension; constructor(resolvedKeybinding, command, commandArgs, when, isDefault, extensionId, isBuiltinExtension) { this.resolvedKeybinding = resolvedKeybinding; this.chords = resolvedKeybinding ? toEmptyArrayIfContainsNull(resolvedKeybinding.getDispatchChords()) : []; if (resolvedKeybinding && this.chords.length === 0) { // handle possible single modifier chord keybindings this.chords = toEmptyArrayIfContainsNull(resolvedKeybinding.getSingleModifierDispatchChords()); } this.bubble = (command ? command.charCodeAt(0) === 94 /* CharCode.Caret */ : false); this.command = this.bubble ? command.substr(1) : command; this.commandArgs = commandArgs; this.when = when; this.isDefault = isDefault; this.extensionId = extensionId; this.isBuiltinExtension = isBuiltinExtension; } } export function toEmptyArrayIfContainsNull(arr) { const result = []; for (let i = 0, len = arr.length; i < len; i++) { const element = arr[i]; if (!element) { return []; } result.push(element); } return result; }