Skip to content

Commit

Permalink
Merge pull request ned-martin#1 from NiavlysB/patch-1
Browse files Browse the repository at this point in the history
Don’t do anything if there is no selection region
  • Loading branch information
ned-martin authored Apr 22, 2021
2 parents 209a840 + 3edd56b commit bb4e63d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions show_unicode_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ def on_activated(self, view):
self.show_unicode(view)

def show_unicode(self, view):
selected = view.substr(view.sel()[0].a)
view.set_status('a-ned-unicode', "U+{0:0>4X} #{0} {1}".format(ord(selected), unicodedata.name(selected, selected.encode('unicode_escape').decode('utf-8')).title()))
regions = view.sel()
if len(regions) > 0:
selected = view.substr(regions[0].a)
view.set_status(
'a-ned-unicode',
"U+{0:0>4X} #{0} {1}".format(
ord(selected),
unicodedata.name(selected, selected.encode('unicode_escape').decode('utf-8')).title()
)
)

0 comments on commit bb4e63d

Please sign in to comment.