diff --git a/Main.sublime-menu b/Main.sublime-menu new file mode 100644 index 0000000..95b4496 --- /dev/null +++ b/Main.sublime-menu @@ -0,0 +1,28 @@ +[ + { + "caption": "Preferences", + "mnemonic": "n", + "id": "preferences", + "children": + [{ + "caption": "Package Settings", + "mnemonic": "P", + "id": "package-settings", + "children": + [{ + "caption": "Highlight Duplicates", + "mnemonic": "H", + "children": + [{ + "caption": "-" + },{ + "command": "open_file", "args": {"file": "${packages}/HighlightDuplicates/highlight_duplicates.sublime-settings"},"caption": "Settings – Default" + },{ + "command": "open_file", "args": {"file": "${packages}/User/highlight_duplicates.sublime-settings"},"caption": "Settings – User" + },{ + "caption": "-" + }] + }] + }] + } +] diff --git a/hightlight_duplicates.py b/hightlight_duplicates.py index 41cd130..2d056db 100644 --- a/hightlight_duplicates.py +++ b/hightlight_duplicates.py @@ -15,6 +15,7 @@ # inspired by https://github.com/SublimeText/TrailingSpaces import sublime import sublime_plugin +import sys from collections import defaultdict DEFAULT_COLOR_SCOPE_NAME = "invalid" @@ -45,7 +46,7 @@ def filter_counts(counts, treshold=1): lower or equal to the treshold, which defaults to 1. ''' filtered = dict() - for k, v in counts.iteritems(): + for k, v in counts.items(): if len(v) > treshold: filtered[k] = v return filtered @@ -66,16 +67,16 @@ def show_lines(regions, view): color_scope_name = settings.get('highlight_duplicates_color', DEFAULT_COLOR_SCOPE_NAME) view.add_regions('DuplicatesHighlightListener', - all_regions, color_scope_name, - sublime.DRAW_OUTLINED) + all_regions, color_scope_name, '', + sublime.DRAW_SQUIGGLY_UNDERLINE) def add_lines(regions, view): '''Merges all duplicated regions in one set and highlights them.''' + view.sel().clear() all_regions = [] for r in regions: for i in r: - print(i) view.sel().add(i) diff --git a/package-metadata.json b/package-metadata.json new file mode 100644 index 0000000..1c07b14 --- /dev/null +++ b/package-metadata.json @@ -0,0 +1 @@ +{"version": "2017.10.17.07.03.59", "platforms": ["*"], "sublime_text": "*", "url": "https://github.com/LordBrom/HighlightDuplicates", "dependencies": [], "description": "Highlight duplicated lines in SublimeText 2"} \ No newline at end of file