From 4a7b9416aa0ac0d55820aff4e9ebee8bdf316a41 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 7 Jan 2024 10:57:54 +0100 Subject: [PATCH] Fix sorting .tags Both files ".tags" and ".tags_sorted_file" are needed. - Goto Definition uses ".tags" - Show Symbols uses ".tags_sorted_file" --- ctags.py | 6 +----- ctagsplugin.py | 11 ----------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/ctags.py b/ctags.py index 027f60e..aba8c22 100644 --- a/ctags.py +++ b/ctags.py @@ -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_: @@ -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 @@ -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 # diff --git a/ctagsplugin.py b/ctagsplugin.py index 18c73c3..58db37e 100644 --- a/ctagsplugin.py +++ b/ctagsplugin.py @@ -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())