Skip to content

Commit

Permalink
Upgrading to Sublime Text 3
Browse files Browse the repository at this point in the history
  • Loading branch information
LordBrom authored Oct 20, 2017
1 parent efee8ca commit 0c1eac6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
28 changes: 28 additions & 0 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
@@ -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": "-"
}]
}]
}]
}
]
9 changes: 5 additions & 4 deletions hightlight_duplicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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)


Expand Down
1 change: 1 addition & 0 deletions package-metadata.json
Original file line number Diff line number Diff line change
@@ -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"}

0 comments on commit 0c1eac6

Please sign in to comment.