Commits

Anonymous committed a331d3c

Restrict to ascii keywords and don't write a file if no keywords found.

Comments (0)

Files changed (3)

plugin/TagHighlight/module/ctags.py

 
     p = open(os.path.join(options['ctags_file_dir'],options['ctags_file']), 'r')
     while 1:
-        line = p.readline()
+        try:
+            line = p.readline()
+        except UnicodeDecodeError:
+            continue
         if not line:
             break
 

plugin/TagHighlight/module/generation.py

 
     if options['check_keywords']:
         iskeyword = GenerateValidKeywordRange(language_handler['IsKeyword'])
-        if config['print_debug']:
+        if options['print_debug']:
             print("Is Keyword is {0!r}".format(iskeyword))
 
     matchEntries = set()
     # Sort the matches
     matchEntries = sorted(list(matchEntries))
 
+    if (len(matchEntries) + len(vimtypes_entries)) == 0:
+        # All keywords have been filtered out, give up
+        return
+
     vimtypes_entries.append('')
     vimtypes_entries += matchEntries
 

plugin/TagHighlight/module/utilities.py

             raise NotImplementedError
 
 def GenerateValidKeywordRange(iskeyword):
+    # Generally obeys Vim's iskeyword setting, but
+    # only allows characters in ascii range
     ValidKeywordSets = iskeyword.split(',')
     rangeMatcher = re.compile('^(?P<from>(?:\d+|\S))-(?P<to>(?:\d+|\S))$')
     falseRangeMatcher = re.compile('^^(?P<from>(?:\d+|\S))-(?P<to>(?:\d+|\S))$')
         m = rangeMatcher.match(valid)
         fm = falseRangeMatcher.match(valid)
         if valid == '@':
-            for ch in [chr(i) for i in range(0,256)]:
+            for ch in [chr(i) for i in range(0,128)]:
                 if ch.isalpha():
                     validList.append(ch)
         elif m is not None:
                 rangeTo = ord(m.group('to'))
 
             validRange = list(range(rangeFrom, rangeTo+1))
+            # Restrict to ASCII
+            validRange = [i for i in validRange if i < 128]
             for ch in [chr(i) for i in validRange]:
                 validList.append(ch)
 
 
         elif len(valid) == 1:
             # Just a char
-            validList.append(valid)
+            if ord(valid) < 128:
+                validList.append(valid)
 
         else:
             raise ValueError('Unrecognised iskeyword part: ' + valid)