Skip to content

Commit

Permalink
fixed sublime package problems all tests are passing
Browse files Browse the repository at this point in the history
  • Loading branch information
zoli committed Sep 14, 2015
1 parent 53b3c30 commit 37a33f6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
11 changes: 6 additions & 5 deletions lib/items/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package items

import (
"io/ioutil"
"path"

"github.com/limetext/lime-backend/lib/log"
)
Expand All @@ -28,16 +29,16 @@ func Register(r Record) {
recs = append(recs, r)
}

func Scan(path string) {
fis, err := ioutil.ReadDir(path)
func Scan(dir string) {
fis, err := ioutil.ReadDir(dir)
if err != nil {
log.Warn("Couldn't read path %s: %s", path, err)
log.Warn("Couldn't read path %s: %s", dir, err)
}

watchDir(&pkgDir{path})
watchDir(&pkgDir{dir})

for _, fi := range fis {
record(fi.Name())
record(path.Join(dir, fi.Name()))
}
}

Expand Down
14 changes: 8 additions & 6 deletions lib/sublime/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func newPlugin(fn string) items.Item {
}

func (p *plugin) Load() error {
fn := p.Name()
s, err := py.NewUnicode(filepath.Dir(fn) + "." + fn[:len(fn)-3])
dir, file := filepath.Split(p.Name())
s, err := py.NewUnicode(filepath.Base(dir) + "." + file[:len(file)-3])
if err != nil {
return err
}
Expand All @@ -59,31 +59,33 @@ func (p *plugin) FileChanged(name string) {
func (p *plugin) loadKeyBindings() {
ed := backend.GetEditor()
tmp := ed.KeyBindings().Parent()
dir := filepath.Dir(p.Name())

ed.KeyBindings().SetParent(p)
p.KeyBindings().SetParent(p.defaultKB)
p.defaultKB.KeyBindings().SetParent(tmp)

pt := path.Join(p.Name(), "Default.sublime-keymap")
pt := path.Join(dir, "Default.sublime-keymap")
items.NewKeymapL(pt, p.defaultKB.KeyBindings())

pt = path.Join(p.Name(), "Default ("+ed.Plat()+").sublime-keymap")
pt = path.Join(dir, "Default ("+ed.Plat()+").sublime-keymap")
items.NewKeymapL(pt, p.KeyBindings())
}

func (p *plugin) loadSettings() {
ed := backend.GetEditor()
tmp := ed.Settings().Parent()
dir := filepath.Dir(p.Name())

ed.Settings().SetParent(p)
p.Settings().SetParent(p.platformSet)
p.platformSet.Settings().SetParent(p.defaultSet)
p.defaultSet.Settings().SetParent(tmp)

pt := path.Join(p.Name(), "Preferences.sublime-settings")
pt := path.Join(dir, "Preferences.sublime-settings")
items.NewSettingL(pt, p.defaultSet.Settings())

pt = path.Join(p.Name(), "Preferences ("+ed.Plat()+").sublime-settings")
pt = path.Join(dir, "Preferences ("+ed.Plat()+").sublime-settings")
items.NewSettingL(pt, p.platformSet.Settings())

pt = path.Join(ed.PackagesPath("user"), "Preferences.sublime-settings")
Expand Down
6 changes: 4 additions & 2 deletions lib/sublime/sublime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ type consoleObserver struct {
T *testing.T
}

func (o *consoleObserver) Erased(changed_buffer text.Buffer, region_removed text.Region, data_removed []rune) {
func (o *consoleObserver) Erased(changed_buffer text.Buffer,
region_removed text.Region, data_removed []rune) {
// do nothing
}

func (o *consoleObserver) Inserted(changed_buffer text.Buffer, region_inserted text.Region, data_inserted []rune) {
func (o *consoleObserver) Inserted(changed_buffer text.Buffer,
region_inserted text.Region, data_inserted []rune) {
o.T.Logf("%s", string(data_inserted))
}

Expand Down

0 comments on commit 37a33f6

Please sign in to comment.