Skip to content

Commit

Permalink
Serialize the proper API object for the keymaps.json file
Browse files Browse the repository at this point in the history
Fixes issue eclipse-theia#9087

Change-Id: I9c636c45654a028459247abc2d175c38bb9aaa58
Signed-off-by: Samuel HULTGREN <samuel.hultgren@st.com>
  • Loading branch information
slhultgren committed Feb 18, 2021
1 parent 4e1c1d4 commit 2dab357
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions packages/core/src/common/keybinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ export interface Keybinding {
args?: any;
}
export namespace Keybinding {
export function apiObjectify(binding: Keybinding): Keybinding {
return {
command: binding.command,
keybinding: binding.keybinding,
context: binding.context,
when: binding.when,
args: binding.args
};
}

/**
* Returns with the string representation of the binding.
Expand All @@ -58,14 +67,7 @@ export namespace Keybinding {
* @param binding the binding to stringify.
*/
export function stringify(binding: Keybinding): string {
const copy: Keybinding = {
command: binding.command,
keybinding: binding.keybinding,
context: binding.context,
when: binding.when,
args: binding.args
};
return JSON.stringify(copy);
return JSON.stringify(apiObjectify(binding));
}

/* Determine whether object is a KeyBinding */
Expand Down
2 changes: 1 addition & 1 deletion packages/keymaps/src/browser/keymaps-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class KeymapsService {
const textModel = model.textEditorModel;
const { insertSpaces, tabSize, defaultEOL } = textModel.getOptions();
const editOperations: monaco.editor.IIdentifiedSingleEditOperation[] = [];
for (const edit of jsoncparser.modify(content, [], keybindings, {
for (const edit of jsoncparser.modify(content, [], keybindings.map(binding => Keybinding.apiObjectify(binding)), {
formattingOptions: {
insertSpaces,
tabSize,
Expand Down

0 comments on commit 2dab357

Please sign in to comment.