Skip to content

Commit

Permalink
Resolved test failiure occured after ce04fc8
Browse files Browse the repository at this point in the history
Because we are initializing setting and keybinding hierarchy on
GetEditor() we should remove the checking in loadSettings() and
loadKeyBindings()
  • Loading branch information
zoli committed Mar 19, 2016
1 parent 98b1029 commit cb459ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
8 changes: 0 additions & 8 deletions lib/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,6 @@ func (e *Editor) SetClipboardFuncs(setter func(string) error, getter func() (str
}

func (e *Editor) loadKeyBindings() {
// Prevent running loadKeyBindings func more than once
if e.KeyBindings().Parent() != nil {
return
}
log.Fine("Loading editor keybindings")

p := path.Join(e.PackagesPath("default"), "Default.sublime-keymap")
Expand All @@ -208,10 +204,6 @@ func (e *Editor) loadKeyBindings() {
}

func (e *Editor) loadSettings() {
// Prevent running loadSettings func more than once
if e.Settings().Parent() != nil {
return
}
log.Fine("Loading editor settings")

p := path.Join(e.PackagesPath("default"), "Preferences.sublime-settings")
Expand Down
12 changes: 6 additions & 6 deletions lib/editor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ func TestGetEditor(t *testing.T) {
}

func TestLoadKeyBinding(t *testing.T) {
editor := GetEditor()
packages.NewJSONL("testdata/Default.sublime-keymap", editor.KeyBindings())
ed := GetEditor()
packages.NewJSONL("testdata/Default.sublime-keymap", ed.KeyBindings())

kb := editor.KeyBindings().Filter(keys.KeyPress{Key: 'i'})
kb := ed.KeyBindings().Filter(keys.KeyPress{Key: 'i'})
if expectedLen := 3; kb.Len() != expectedLen {
t.Errorf("Expected to have %d keys in the filter, but it had %d", expectedLen, kb.Len())
}
}

func TestLoadKeyBindings(t *testing.T) {
editor := GetEditor()
editor.loadKeyBindings()
ed := GetEditor()
ed.loadKeyBindings()

if editor.defaultKB.KeyBindings().Len() <= 0 {
if ed.defaultKB.KeyBindings().Len() <= 0 {
t.Errorf("Expected editor to have some keys bound, but it didn't")
}
}
Expand Down

0 comments on commit cb459ef

Please sign in to comment.