diff options
author | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2016-11-04 15:14:07 +0900 |
---|---|---|
committer | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2016-11-04 15:14:07 +0900 |
commit | fd2d15851a1b56a851954222cae9af0ac08b3a9c (patch) | |
tree | 622390505573f5c9e1cf7014a851d571dc205525 /rplugin | |
parent | 80b2fb6044456b18e77659e56741abaf106b0b58 (diff) | |
download | deoplete.nvim-fd2d15851a1b56a851954222cae9af0ac08b3a9c.zip |
Improve gather_candidates in buffer source by @tweekmonster
Diffstat (limited to 'rplugin')
-rw-r--r-- | rplugin/python3/deoplete/source/buffer.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/rplugin/python3/deoplete/source/buffer.py b/rplugin/python3/deoplete/source/buffer.py index 3ed4eb8..dce6a7e 100644 --- a/rplugin/python3/deoplete/source/buffer.py +++ b/rplugin/python3/deoplete/source/buffer.py @@ -6,7 +6,7 @@ from .base import Base -import functools +import itertools import operator from deoplete.util import parse_buffer_pattern, getlines @@ -29,13 +29,11 @@ class Source(Base): def gather_candidates(self, context): self.__make_cache(context) - buffers = [x['candidates'] for x in self.__buffers.values() - if x['filetype'] in context['filetypes']] - if not buffers: - return [] - - return [{'word': x} for x in - functools.reduce(operator.add, buffers)] + same_filetype = True + candidates = (x['candidates'] for x in self.__buffers.values() + if not same_filetype or + x['filetype'] in context['filetypes']) + return [{'word': x} for x in itertools.chain(*candidates)] def __make_cache(self, context): try: |