Skip to content
Browse files

Always do the regex search first. Better regex pattern

  • Loading branch information...
1 parent 8513149 commit 226a52cafd8140922bf20c28446be0c22f64d270 @quarnster committed Aug 7, 2012
Showing with 12 additions and 13 deletions.
  1. +2 −2 package.json
  2. +10 −11 sublimeclang.py
View
4 package.json
@@ -6,11 +6,11 @@
"description": "C/C++/ObjC/ObjC++ autocompletions and code navigation",
"author": "Fredrik Ehnbom (quarnster)",
"homepage": "http://github.com/quarnster/SublimeClang",
- "last_modified": "2012-08-07 08:15:00",
+ "last_modified": "2012-08-07 08:55:00",
"platforms": {
"*": [
{
- "version": "1.0.27",
+ "version": "1.0.28",
"url": "http://cloud.github.com/downloads/quarnster/SublimeClang/SublimeClang.sublime-package"
}
]
View
21 sublimeclang.py
@@ -169,7 +169,7 @@ class ClangGotoImplementation(sublime_plugin.TextCommand):
class ExtensiveSearch:
def __init__(self, cursor, view, window, name):
self.name = name
- self.re = re.compile(r"(\s|::|\*|&)(%s\s*\([^;\{]*\))\s*\{" % cursor.spelling)
+ self.re = re.compile(r"(\w+\s+|\w+::|\*|&)(%s\s*\([^;\{]*\))\s*\{" % cursor.spelling)
self.view = view
self.target = ""
self.cursor = cursor
@@ -241,16 +241,15 @@ def worker(self):
remove = translationunitcache.tuCache.get_status(name) == translationunitcache.TranslationUnitCache.STATUS_NOT_IN_CACHE
fine_search = not remove
- if remove:
- # try a regex search first
- f = file(name, "r")
- data = f.read()
- f.close()
- match = self.re.search(data)
- if match != None:
- fine_search = True
- line, column = parsehelp.get_line_and_column_from_offset(data, match.start())
- self.candidates.put((name, match.group(2), line, column))
+ # try a regex search first
+ f = file(name, "r")
+ data = f.read()
+ f.close()
+ match = self.re.search(data)
+ if match != None:
+ fine_search = True
+ line, column = parsehelp.get_line_and_column_from_offset(data, match.start())
+ self.candidates.put((name, "".join(match.groups()), line, column))
if fine_search:
tu2 = translationunitcache.tuCache.get_translation_unit(name, opts, opts_script)

0 comments on commit 226a52c

Please sign in to comment.
Something went wrong with that request. Please try again.