diff --git a/show_unicode_name.py b/show_unicode_name.py index 7459083..549a3dc 100644 --- a/show_unicode_name.py +++ b/show_unicode_name.py @@ -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() + ) + )