From 2fb173e9f31b4c3c9886be6ed87647ab139bd5d1 Mon Sep 17 00:00:00 2001 From: GhostBarik Date: Mon, 9 Jun 2014 21:44:24 +0200 Subject: [PATCH 1/3] fixed 'object has no attribute by_source/by_cabal' issues --- symbols.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/symbols.py b/symbols.py index 10381fab..c36cf161 100644 --- a/symbols.py +++ b/symbols.py @@ -43,8 +43,8 @@ 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) + if self.location: + self.location.filename = module_loc else: self.location = module_loc @@ -129,15 +129,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(): - info.append('') - info.append('Installed in {0} in package {1}'.format(self.location.cabal, self.location.package.package_id())) + + if hasattr(self.location, 'cabal'): + info.append('') + info.append('Installed in {0} in package {1}'.format(self.location.cabal, self.location.package.package_id())) return '\n'.join(info) @@ -226,7 +227,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) From 52eaa6dad496ccaa20940ec7f8a9aac995d74b5b Mon Sep 17 00:00:00 2001 From: GhostBarik Date: Mon, 9 Jun 2014 21:44:24 +0200 Subject: [PATCH 2/3] fixed 'object has no attribute by_source/by_cabal' issues --- symbols.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/symbols.py b/symbols.py index 10381fab..5b9f9e91 100644 --- a/symbols.py +++ b/symbols.py @@ -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 @@ -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) @@ -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) From 1bfd125be9377ec1bc79d3b5846ca0c093b4fe1f Mon Sep 17 00:00:00 2001 From: GhostBarik Date: Tue, 10 Jun 2014 00:22:11 +0200 Subject: [PATCH 3/3] fixing missing quick panel 'Select imported module' by calling sublime.set_timeout --- autocomplete.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/autocomplete.py b/autocomplete.py index b313b73d..c0dc98d6 100644 --- a/autocomplete.py +++ b/autocomplete.py @@ -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) @@ -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: