335
}
336
337
>
function removeKeybindings(content: string, command: string, formattingOptions: FormattingOptions): string {
keybindingsMerge.ts
338
>
const keybindings = parseKeybindings(content);
339
>
for (let index = keybindings.length - 1; index >= 0; index--) {
340
>
if (keybindings[index].command === command || keybindings[index].command === `-${command}`) {
341
content = contentUtil.edit(content, [index], undefined, formattingOptions);
342
}
344
>
return content;
345
>
}
346
347
>
function updateKeybindings(content: string, command: string, keybindings: IUserFriendlyKeybinding[], formattingOptions: FormattingOptions): string {
keybindingsMerge.ts
348
>
const allKeybindings = parseKeybindings(content);
349
>
const location = allKeybindings.findIndex(keybinding => keybinding.command === command || keybinding.command === `-${command}`);
350
>
// Remove all entries with this command
351
>
for (let index = allKeybindings.length - 1; index >= 0; index--) {
352
>
if (allKeybindings[index].command === command || allKeybindings[index].command === `-${command}`) {
353
>
content = contentUtil.edit(content, [index], undefined, formattingOptions);
354
>
}
355
>
}
356
>
// add all entries at the same location where the entry with this command was located.
357
>
for (let index = keybindings.length - 1; index >= 0; index--) {
358
>
content = contentUtil.edit(content, [location], keybindings[index], formattingOptions);
359
>
}
360
>
return content;
361
>
}