Skip to content

Commit

Permalink
Merge pull request #154 from GhostBarik/master
Browse files Browse the repository at this point in the history
fixed some of the attribute access exceptions in 'symbols.py' and restored panel 'select imported module'
  • Loading branch information
mvoidex committed Jun 13, 2014
2 parents 9752d64 + ba6c0c7 commit 69e9cf3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 5 additions & 2 deletions autocomplete.py
Expand Up @@ -521,7 +521,7 @@ def run(self, edit, filename = None, module_name = None, decl = None):
self.candidates = [(m, ident) for m in import_list]
self.view.window().show_quick_panel([
['Select imported module', 'from where {0} may be imported'.format(ident)],
['No, thanks']], self.on_import_selected)
['No, thanks', '']], self.on_import_selected)
return

show_status_message('Symbol "{0}" not found'.format(ident), False)
Expand All @@ -545,7 +545,10 @@ def on_done(self, idx):

def on_import_selected(self, idx):
if idx == 0: # Yes, select imported module
self.view.window().show_quick_panel(['{0}.{1}'.format(i[0], i[1]) for i in self.candidates], self.on_candidate_selected)
sublime.set_timeout(
lambda: self.view.window().show_quick_panel(['{0}.{1}'.format(i[0], i[1]) for i in self.candidates],
self.on_candidate_selected), 10
)

def on_candidate_selected(self, idx):
if idx == -1:
Expand Down
14 changes: 6 additions & 8 deletions symbols.py
Expand Up @@ -43,10 +43,7 @@ def update_location(self, module_loc):
JSON contains only line + column
This function used to merge module location, which contains all other info with line + column
"""
if self.location and self.by_source():
self.location.set_file(module_loc)
else:
self.location = module_loc
self.location = module_loc

def full_name(self):
return self.module.name + '.' + self.name
Expand Down Expand Up @@ -129,15 +126,16 @@ def detailed(self):
if self.docs:
info.extend(['', self.docs])

if self.by_source():
if self.location:
info.append('')
if self.location.project:
info.append('Defined in {0} at {1}'.format(self.location.project, self.location.position()))
else:
info.append('Defined at {0}'.format(self.location.position()))
if self.by_cabal():

if self.module and self.module.cabal:
info.append('')
info.append('Installed in {0} in package {1}'.format(self.location.cabal, self.location.package.package_id()))
info.append('Installed in {0}'.format(self.module.cabal))

return '\n'.join(info)

Expand Down Expand Up @@ -226,7 +224,7 @@ def same_module(l, r):
and modules defined in one file, in same cabal-dev sandbox or in cabal
"""
same_cabal = l.cabal and r.cabal and (l.cabal == r.cabal)
same_filename = l.by_source() and r.by_source() and (l.location.filename == r.location.filename)
same_filename = l.location and r.location and (l.location.filename == r.location.filename)
nowhere = (not l.cabal) and (not l.location) and (not r.cabal) and (not r.location)
return l.name == r.name and (same_cabal or same_filename or nowhere)

Expand Down

0 comments on commit 69e9cf3

Please sign in to comment.