summaryrefslogtreecommitdiff
path: root/rplugin
diff options
context:
space:
mode:
authorShougo Matsushita <Shougo.Matsu@gmail.com>2016-06-17 07:37:05 +0900
committerShougo Matsushita <Shougo.Matsu@gmail.com>2016-06-17 07:37:05 +0900
commit54cd0d76162fa6c60a4f933387216ecc1369abf1 (patch)
treece8d68192a2144a5982915b9cddec89984d8d8b5 /rplugin
parentd19017067c9496b0fd61fa7ec2aa4a08f39cf37a (diff)
downloaddeoplete.nvim-54cd0d76162fa6c60a4f933387216ecc1369abf1.zip
Improve make cache
Diffstat (limited to 'rplugin')
-rw-r--r--rplugin/python3/deoplete/sources/tag.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/rplugin/python3/deoplete/sources/tag.py b/rplugin/python3/deoplete/sources/tag.py
index 3250682..41d6e5a 100644
--- a/rplugin/python3/deoplete/sources/tag.py
+++ b/rplugin/python3/deoplete/sources/tag.py
@@ -24,21 +24,13 @@ class Source(Base):
self.mark = '[T]'
self.__cache = {}
+ self.__tagfiles = {}
def on_event(self, context):
- self.__make_cache(context)
+ self.__tagfiles[context['bufnr']] = self.__get_tagfiles(context)
- def gather_candidates(self, context):
- candidates = []
- for filename in [x for x in self.__get_tagfiles(context)
- if x in self.__cache]:
- candidates += self.__cache[filename].candidates
-
- p = re.compile('(?:{})$'.format(context['keyword_patterns']))
- return [{'word': x} for x in candidates if p.match(x)]
-
- def __make_cache(self, context):
- for filename in self.__get_tagfiles(context):
+ # Make cache
+ for filename in self.__tagfiles[context['bufnr']]:
mtime = getmtime(filename)
if filename not in self.__cache or self.__cache[
filename].mtime != mtime:
@@ -46,6 +38,16 @@ class Source(Base):
self.__cache[filename] = TagsCacheItem(
mtime, parse_file_pattern(f, '^[^!][^\t]+'))
+ def gather_candidates(self, context):
+ candidates = []
+ for filename in [
+ x for x in self.__tagfiles.get(context['bufnr'], [])
+ if x in self.__cache]:
+ candidates += self.__cache[filename].candidates
+
+ p = re.compile('(?:{})$'.format(context['keyword_patterns']))
+ return [{'word': x} for x in candidates if p.match(x)]
+
def __get_tagfiles(self, context):
limit = context['vars']['deoplete#tag#cache_limit_size']
include_files = self.vim.call(