Skip to content

Commit 55e8368

Browse files
committed
fix: add missing version number in xcode config
1 parent 60f2a9f commit 55e8368

21 files changed

Lines changed: 624 additions & 251 deletions

config/action_mappings/edit_find.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ mappings:
8585
xcode:
8686
action: "findInWorkspace:"
8787
alternate: "NO"
88+
commandGroupID: "Xcode.IDEKit.CmdDefinition.FindInWorkspace"
8889
commandID: "Xcode.IDEKit.CmdDefinition.FindInWorkspace"
8990
group: "Find Menu"
9091
groupID: "Xcode.IDEKit.MenuDefinition.Main"

internal/plugins/intellij/export.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (e *intellijExporter) generateManagedActions(setting *keymapv1.Keymap) []Ac
129129
if b == nil {
130130
continue
131131
}
132-
shortcutXML, err := formatKeybinding(keymap.NewKeyBinding(b))
132+
shortcutXML, err := FormatKeybinding(keymap.NewKeyBinding(b))
133133
if err != nil {
134134
e.logger.Warn("failed to format keybinding", "action", km.GetName(), "error", err)
135135
continue

internal/plugins/intellij/import.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (p *intellijImporter) Import(
6666
if ks.First == "" {
6767
continue
6868
}
69-
kb, err := parseKeyBinding(ks)
69+
kb, err := ParseKeyBinding(ks)
7070
if err != nil {
7171
p.logger.WarnContext(ctx, "failed to parse key binding", "binding", ks, "error", err)
7272
continue

internal/plugins/intellij/keybinding.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
const maxIntellijChords = 2
1515

16-
func parseKeyBinding(ks KeyboardShortcutXML) (*keymap.KeyBinding, error) {
16+
func ParseKeyBinding(ks KeyboardShortcutXML) (*keymap.KeyBinding, error) {
1717
parts1, err := parseKeyStroke(ks.First)
1818
if err != nil {
1919
return nil, err
@@ -34,7 +34,7 @@ func parseKeyBinding(ks KeyboardShortcutXML) (*keymap.KeyBinding, error) {
3434
return keymap.ParseKeyBinding(first+" "+second, "+")
3535
}
3636

37-
func formatKeybinding(keybind *keymap.KeyBinding) (*KeyboardShortcutXML, error) {
37+
func FormatKeybinding(keybind *keymap.KeyBinding) (*KeyboardShortcutXML, error) {
3838
// Only support up to two chords for IntelliJ (first and optional second keystroke).
3939
chords := keybind.GetKeyChords().GetChords()
4040
if len(chords) > maxIntellijChords {

internal/plugins/intellij/keybinding_test.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package intellij
1+
package intellij_test
22

33
import (
44
"testing"
@@ -7,29 +7,34 @@ import (
77
"github.com/stretchr/testify/require"
88
"github.com/xinnjie/onekeymap-cli/internal/keymap"
99
"github.com/xinnjie/onekeymap-cli/internal/platform"
10+
"github.com/xinnjie/onekeymap-cli/internal/plugins/intellij"
1011
keymapv1 "github.com/xinnjie/onekeymap-cli/protogen/keymap/v1"
1112
)
1213

1314
func TestParseKeyBinding_Table(t *testing.T) {
1415
tests := []struct {
1516
name string
16-
in KeyboardShortcutXML
17+
in intellij.KeyboardShortcutXML
1718
want string
1819
wantErr bool
1920
}{
20-
{name: "SingleChord", in: KeyboardShortcutXML{First: "alt HOME"}, want: "alt+home"},
21-
{name: "TwoChords", in: KeyboardShortcutXML{First: "control E", Second: "control S"}, want: "ctrl+e ctrl+s"},
22-
{name: "InvalidFirst", in: KeyboardShortcutXML{First: "control UNKNOWN_KEY"}, wantErr: true},
21+
{name: "SingleChord", in: intellij.KeyboardShortcutXML{First: "alt HOME"}, want: "alt+home"},
22+
{
23+
name: "TwoChords",
24+
in: intellij.KeyboardShortcutXML{First: "control E", Second: "control S"},
25+
want: "ctrl+e ctrl+s",
26+
},
27+
{name: "InvalidFirst", in: intellij.KeyboardShortcutXML{First: "control UNKNOWN_KEY"}, wantErr: true},
2328
{
2429
name: "InvalidSecond",
25-
in: KeyboardShortcutXML{First: "alt HOME", Second: "control UNKNOWN_KEY"},
30+
in: intellij.KeyboardShortcutXML{First: "alt HOME", Second: "control UNKNOWN_KEY"},
2631
wantErr: true,
2732
},
2833
}
2934

3035
for _, tc := range tests {
3136
t.Run(tc.name, func(t *testing.T) {
32-
kb, err := parseKeyBinding(tc.in)
37+
kb, err := intellij.ParseKeyBinding(tc.in)
3338
if tc.wantErr {
3439
require.Error(t, err)
3540
assert.Nil(t, kb)
@@ -72,7 +77,7 @@ func TestFormatKeybinding_Table(t *testing.T) {
7277
} else {
7378
kb = keymap.MustParseKeyBinding(tc.in)
7479
}
75-
ks, err := formatKeybinding(kb)
80+
ks, err := intellij.FormatKeybinding(kb)
7681
if tc.wantErr {
7782
require.Error(t, err)
7883
assert.Nil(t, ks)

internal/plugins/vscode/export.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (e *vscodeExporter) generateManagedKeybindings(setting *keymapv1.Keymap) []
179179
continue
180180
}
181181
binding := keymap.NewKeyBinding(b)
182-
keys, err := formatKeybinding(binding)
182+
keys, err := FormatKeybinding(binding)
183183
if err != nil {
184184
e.logger.Warn("Skipping keybinding with un-formattable key", "action", km.GetName(), "error", err)
185185
continue

internal/plugins/vscode/import.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (i *vscodeImporter) Import(
7777
continue
7878
}
7979

80-
kb, err := parseKeybinding(binding.Key)
80+
kb, err := ParseKeybinding(binding.Key)
8181
if err != nil {
8282
i.logger.WarnContext(ctx, "Skipping keybinding with unparsable key", "key", binding.Key, "error", err)
8383
continue

internal/plugins/vscode/keybinding.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77

88
const vscodeKeyChordSeparator = "+"
99

10-
func parseKeybinding(keybind string) (*keymap.KeyBinding, error) {
10+
func ParseKeybinding(keybind string) (*keymap.KeyBinding, error) {
1111
return keymap.ParseKeyBinding(keybind, vscodeKeyChordSeparator)
1212
}
1313

14-
func formatKeybinding(keybind *keymap.KeyBinding) (string, error) {
14+
func FormatKeybinding(keybind *keymap.KeyBinding) (string, error) {
1515
return keybind.Format(platform.PlatformMacOS, vscodeKeyChordSeparator)
1616
}

internal/plugins/vscode/keybinding_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package vscode
1+
package vscode_test
22

33
import (
44
"testing"
@@ -7,6 +7,7 @@ import (
77
"github.com/stretchr/testify/require"
88
"github.com/xinnjie/onekeymap-cli/internal/keymap"
99
"github.com/xinnjie/onekeymap-cli/internal/platform"
10+
"github.com/xinnjie/onekeymap-cli/internal/plugins/vscode"
1011
)
1112

1213
func TestVSCode_FormatKeybinding(t *testing.T) {
@@ -25,7 +26,7 @@ func TestVSCode_FormatKeybinding(t *testing.T) {
2526
for _, tc := range tests {
2627
t.Run(tc.name, func(t *testing.T) {
2728
kb := keymap.MustParseKeyBinding(tc.in)
28-
out, err := formatKeybinding(kb)
29+
out, err := vscode.FormatKeybinding(kb)
2930
require.NoError(t, err)
3031
assert.Equal(t, tc.want, out)
3132
})
@@ -50,7 +51,7 @@ func TestVSCode_ParseKeybinding(t *testing.T) {
5051

5152
for _, tc := range tests {
5253
t.Run(tc.name, func(t *testing.T) {
53-
kb, err := parseKeybinding(tc.in)
54+
kb, err := vscode.ParseKeybinding(tc.in)
5455
if tc.wantErr {
5556
require.Error(t, err)
5657
assert.Nil(t, kb)

internal/plugins/xcode/export.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import (
1515
"howett.net/plist"
1616
)
1717

18+
const (
19+
xcodeVersion = 3
20+
)
21+
1822
var (
1923
_ pluginapi.PluginExporter = (*xcodeExporter)(nil)
2024
)
@@ -118,9 +122,11 @@ func (e *xcodeExporter) Export(
118122
plistData := xcodeKeybindingsPlist{
119123
MenuKeyBindings: menuKeyBindings{
120124
KeyBindings: finalKeybindings,
125+
Version: xcodeVersion,
121126
},
122127
TextKeyBindings: textKeyBindings{
123128
KeyBindings: finalTextKeybindings,
129+
Version: xcodeVersion,
124130
},
125131
}
126132

@@ -189,7 +195,7 @@ func (e *xcodeExporter) generateManagedKeybindings(setting *keymapv1.Keymap) []x
189195
continue
190196
}
191197
binding := keymap.NewKeyBinding(b)
192-
keys, err := formatKeybinding(binding)
198+
keys, err := FormatKeybinding(binding)
193199
if err != nil {
194200
e.logger.Warn("Skipping keybinding with un-formattable key", "action", km.GetName(), "error", err)
195201
continue
@@ -201,6 +207,7 @@ func (e *xcodeExporter) generateManagedKeybindings(setting *keymapv1.Keymap) []x
201207
xcodeKeybindings = append(xcodeKeybindings, xcodeKeybinding{
202208
Action: xcodeConfig.Action,
203209
CommandID: xcodeConfig.CommandID,
210+
CommandGroupID: xcodeConfig.CommandGroupID,
204211
KeyboardShortcut: keys,
205212
Title: xcodeConfig.Title,
206213
Alternate: xcodeConfig.Alternate,
@@ -271,7 +278,7 @@ func (e *xcodeExporter) generateTextKeyBindings(
271278
continue
272279
}
273280
binding := keymap.NewKeyBinding(b)
274-
keys, err := formatKeybinding(binding)
281+
keys, err := FormatKeybinding(binding)
275282
if err != nil {
276283
e.logger.Warn("Skipping text keybinding with un-formattable key", "action", km.GetName(), "error", err)
277284
continue

0 commit comments

Comments
 (0)