Skip to content

Commit

Permalink
Fix sorting .tags
Browse files Browse the repository at this point in the history
Both files ".tags" and ".tags_sorted_file" are needed.

- Goto Definition uses ".tags"
- Show Symbols uses ".tags_sorted_file"
  • Loading branch information
deathaxe committed Jan 7, 2024
1 parent babb1a9 commit 4a7b941
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
6 changes: 1 addition & 5 deletions ctags.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ def resort_ctags(tag_file):
"""
meta = []
symbols = []
tmp_file = tag_file + '.tmp'

with codecs.open(tag_file, encoding='utf-8', errors='replace') as file_:
for line in file_:
Expand All @@ -373,7 +372,7 @@ def resort_ctags(tag_file):
meta.sort()
symbols.sort()

with codecs.open(tmp_file, 'w', encoding='utf-8',
with codecs.open(tag_file + '_sorted_by_file', 'w', encoding='utf-8',
errors='replace') as file_:

# write sourted metadata
Expand All @@ -384,9 +383,6 @@ def resort_ctags(tag_file):
split[FILENAME] = split[FILENAME].lstrip('.\\')
file_.write('\t'.join(split))

os.remove(tag_file)
os.rename(tmp_file, tag_file)

#
# Models
#
Expand Down
11 changes: 0 additions & 11 deletions ctagsplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,17 +772,6 @@ def run(self, view, args, tags_file):

files = [key]

# Note: Help migrating existing tags files to new file name.
# Needed, because this plugin now sorts .tags file in-place,
# while former versions used to create a dedicated file.
sorted_tags_file = tags_file + '_sorted_by_file'
if os.path.isfile(sorted_tags_file):
try:
os.remove(tags_file)
os.rename(sorted_tags_file, tags_file)
except OSError:
pass

base_path = get_common_ancestor_folder(
view.file_name(), view.window().folders())

Expand Down

0 comments on commit 4a7b941

Please sign in to comment.