99import re
1010import string
1111import threading
12+ import subprocess
1213
1314from itertools import chain
1415from operator import itemgetter as iget
5152ENTITY_SCOPE = 'entity.name.function, entity.name.type, meta.toc-list'
5253
5354RUBY_SPECIAL_ENDINGS = '\?|!'
54- RUBY_SCOPES = '.*(ruby|rails).*'
5555
5656ON_LOAD = sublime_plugin .all_callbacks ['on_load' ]
5757
@@ -676,7 +676,6 @@ class NavigateToDefinition(sublime_plugin.TextCommand):
676676
677677 def __init__ (self , args ):
678678 sublime_plugin .TextCommand .__init__ (self , args )
679- self .scopes = re .compile (RUBY_SCOPES )
680679 self .endings = re .compile (RUBY_SPECIAL_ENDINGS )
681680
682681 def is_visible (self ):
@@ -687,6 +686,13 @@ def run(self, view, args, tags_file):
687686 region = view .sel ()[0 ]
688687 if region .begin () == region .end (): # point
689688 region = view .word (region )
689+
690+ # handle special line endings for Ruby
691+ language = view .settings ().get ('syntax' )
692+ endings = view .substr (sublime .Region (region .end (), region .end ()+ 1 ))
693+
694+ if 'Ruby' in language and self .endings .match (endings ):
695+ region = sublime .Region (region .begin (), region .end ()+ 1 )
690696 symbol = view .substr (region )
691697
692698 return JumpToDefinition .run (symbol , view , tags_file )
@@ -868,15 +874,19 @@ def tags_built(tag_file):
868874 recursive = recursive , opts = opts ,
869875 cmd = command )
870876 except IOError as e :
871- error_message (str ( e ). rstrip () )
877+ error_message (e . strerror )
872878 return
873- except EnvironmentError as e :
874- if not isinstance (e .strerror , str ):
875- str_err = ' ' .join (e .strerror .decode ('utf-8' ).splitlines ())
879+ except subprocess .CalledProcessError as e :
880+ if sublime .platform () == 'windows' :
881+ str_err = ' ' .join (
882+ e .output .decode ('windows-1252' ).splitlines ())
876883 else :
877- str_err = str ( e ) .rstrip ()
878- error_message (str_err ) # show error_message
884+ str_err = e . output .rstrip ()
885+ error_message (str_err )
879886 return
887+ except Exception as e :
888+ error_message ("An unknown error occured.\n Check the console for info." )
889+ raise e
880890
881891 tags_built (result )
882892
0 commit comments