Skip to content

Commit ae48221

Browse files
committed
Merge branch 'development'
2 parents 4776c2f + 8957730 commit ae48221

File tree

3 files changed

+16
-34
lines changed

3 files changed

+16
-34
lines changed

Default.sublime-commands

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
"caption": "CTags: Show Symbols (file)",
88
"command": "show_symbols",
99
},
10+
{
11+
"caption": "CTags: Show Symbols (current language)",
12+
"command": "show_symbols",
13+
"args": {
14+
"type": "lang"
15+
},
16+
},
1017
{
1118
"caption": "CTags: Show Symbols (all)",
1219
"command": "show_symbols",

ctags.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -353,39 +353,24 @@ def resort_ctags(tag_file):
353353
354354
:returns: None
355355
"""
356-
meta = []
357-
symbols = []
358-
tmp_file = tag_file + '.tmp'
356+
groups = {}
359357

360358
with codecs.open(tag_file, encoding='utf-8', errors='replace') as file_:
361359
for line in file_:
360+
# meta data not needed in sorted files
362361
if line.startswith('!_TAG'):
363-
meta.append(line)
364362
continue
365363

366364
# read all valid symbol tags, which contain at least
367365
# symbol name and containing file and build a list of tuples
368-
split = line.split('\t')
366+
split = line.split('\t', FILENAME + 1)
369367
if len(split) > FILENAME:
370-
symbols.append((split[FILENAME], split))
368+
groups.setdefault(split[FILENAME], []).append(line)
371369

372-
# sort inplace to save some RAM with large .tags files
373-
meta.sort()
374-
symbols.sort()
375-
376-
with codecs.open(tmp_file, 'w', encoding='utf-8',
370+
with codecs.open(tag_file + '_sorted_by_file', 'w', encoding='utf-8',
377371
errors='replace') as file_:
378-
379-
# write sourted metadata
380-
file_.writelines(meta)
381-
382-
# followed by sorted list of symbols
383-
for _, split in symbols:
384-
split[FILENAME] = split[FILENAME].lstrip('.\\')
385-
file_.write('\t'.join(split))
386-
387-
os.remove(tag_file)
388-
os.rename(tmp_file, tag_file)
372+
for group in sorted(groups):
373+
file_.writelines(groups[group])
389374

390375
#
391376
# Models

ctagsplugin.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ def run(self, view, args, tags_file):
758758
# filter and cache by file suffix
759759
suffix = get_current_file_suffix(view.file_name())
760760
key = suffix
761+
files = []
761762
elif multi:
762763
# request all symbols of given tags file
763764
key = "__all__"
@@ -769,20 +770,9 @@ def run(self, view, args, tags_file):
769770
return
770771
key = get_rel_path_to_source(key, tags_file)
771772
key = key.replace('\\', '/')
772-
773773
files = [key]
774774

775-
# Note: Help migrating existing tags files to new file name.
776-
# Needed, because this plugin now sorts .tags file in-place,
777-
# while former versions used to create a dedicated file.
778-
sorted_tags_file = tags_file + '_sorted_by_file'
779-
if os.path.isfile(sorted_tags_file):
780-
try:
781-
os.remove(tags_file)
782-
os.rename(sorted_tags_file, tags_file)
783-
except OSError:
784-
pass
785-
775+
tags_file = tags_file + '_sorted_by_file'
786776
base_path = get_common_ancestor_folder(
787777
view.file_name(), view.window().folders())
788778

0 commit comments

Comments
 (0)