Skip to content

Commit 5f5880b

Browse files
committed
Merge branch 'development'
2 parents cbd7caf + 3cfd53b commit 5f5880b

9 files changed

+324
-24
lines changed

.travis.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# After changing this file, check it on:
2+
# http://lint.travis-ci.org/
3+
language: python
4+
python:
5+
- "2.6" # sublime text 2
6+
- "3.3" # sublime text 3
7+
before_install:
8+
- sudo apt-get install exuberant-ctags
9+
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install unittest2; fi
10+
script:
11+
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then python -m unittest2.__main__ discover; fi
12+
- if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then python -m unittest discover; fi

README.rst

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
CTags
33
=====
44

5+
.. image:: https://travis-ci.org/SublimeText/CTags.png?branch=development :target: https://travis-ci.org/SublimeText/CTags
6+
57
About
68
=====
79

ctags.py

+16-9
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@
55
import codecs
66
import re
77
import os
8+
import sys
89
import subprocess
910
import bisect
1011
import mmap
1112

13+
if sys.version_info<(2,7,0):
14+
from helpers.check_output import check_output
15+
else:
16+
from subprocess import check_output
17+
1218
"""
1319
Contants
1420
"""
1521

1622
TAGS_RE = re.compile(
1723
r'(?P<symbol>[^\t]+)\t'
1824
r'(?P<filename>[^\t]+)\t'
19-
r'(?P<ex_command>.*?\$/);"\t'
25+
r'(?P<ex_command>(/.+/|\?.+\?|\d+));"\t'
2026
r'(?P<type>[^\t\r\n]+)'
2127
r'(?:\t(?P<fields>.*))?'
2228
)
@@ -89,6 +95,8 @@ def parse_tag_lines(lines, order_by='symbol', tag_class=None, filters=[]):
8995
if isinstance(line, Tag): # handle both text and tag objects
9096
line = line.line
9197

98+
line = line.rstrip('\r\n')
99+
92100
search_obj = TAGS_RE.search(line)
93101

94102
if not search_obj:
@@ -304,15 +312,14 @@ def build_ctags(path, tag_file=None, recursive=False, opts=None, cmd=None,
304312
else: # search all files in current directory
305313
cmd.append(os.path.join(path, '*'))
306314

307-
# execute the command
308-
p = subprocess.Popen(cmd, cwd=cwd, shell=False, env=env,
309-
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
310-
stderr=subprocess.STDOUT)
315+
# workaround for the issue described here:
316+
# http://bugs.python.org/issue6689
317+
if os.name == 'posix':
318+
cmd = ' '.join(cmd)
311319

312-
ret = p.wait()
313-
314-
if ret:
315-
raise EnvironmentError(ret, p.stdout.read())
320+
# execute the command
321+
check_output(cmd, cwd=cwd, shell=True, env=env, stdin=subprocess.PIPE,
322+
stderr=subprocess.STDOUT)
316323

317324
if not tag_file: # Exuberant ctags defaults to ``tags`` filename.
318325
tag_file = os.path.join(cwd, 'tags')

ctagsplugin.py

+18-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import re
1010
import string
1111
import threading
12+
import subprocess
1213

1314
from itertools import chain
1415
from operator import itemgetter as iget
@@ -51,7 +52,6 @@
5152
ENTITY_SCOPE = 'entity.name.function, entity.name.type, meta.toc-list'
5253

5354
RUBY_SPECIAL_ENDINGS = '\?|!'
54-
RUBY_SCOPES = '.*(ruby|rails).*'
5555

5656
ON_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.\nCheck the console for info.")
889+
raise e
880890

881891
tags_built(result)
882892

helpers/check_output.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
3+
# Based on source from here: https://gist.github.com/edufelipe/1027906
4+
5+
"""Backport version of 'subprocess.check_output' for Python 2.6.x"""
6+
7+
import subprocess
8+
9+
def check_output(*popenargs, **kwargs):
10+
r"""Run command with arguments and return its output as a byte string.
11+
12+
Backported from Python 2.7 as it's implemented as pure python on stdlib.
13+
14+
>>> check_output(['/usr/bin/python', '--version'])
15+
Python 2.6.2
16+
"""
17+
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
18+
output, unused_err = process.communicate()
19+
retcode = process.poll()
20+
if retcode:
21+
cmd = kwargs.get("args")
22+
if cmd is None:
23+
cmd = popenargs[0]
24+
error = subprocess.CalledProcessError(retcode, cmd)
25+
error.output = output
26+
raise error
27+
return output

messages.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"0.3.3": "messages/0.3.3.md",
77
"0.3.4": "messages/0.3.4.md",
88
"0.3.5": "messages/0.3.5.md",
9-
"0.3.6": "messages/0.3.6.md"
9+
"0.3.6": "messages/0.3.6.md",
10+
"0.3.7": "messages/0.3.7.md"
1011
}

messages/0.3.7.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Changes in 0.3.7
2+
================
3+
4+
- Resolve regressions caused by multiple previous releases
5+
- General improvements in error handling and other corner cases
6+
- Bug Fixes
7+
8+
Fixes
9+
=====
10+
11+
* Ruby: Exception and ? ignored., #177
12+
* Can't Jump to the definition which defined by #define, #213
13+
14+
Resolves
15+
========
16+
17+
* Travis-ci Integration, #218
18+
* Tests aren't cross platform, #219
19+
* Better formatted build warnings #220
20+
21+
*******************************************************************************
22+
23+
For more detailed information about these changes, run ``git v0.3.6..v0.3.7``
24+
on the Git repository found [here](https://github.com/SublimeText/CTags).

0 commit comments

Comments
 (0)