Skip to content

Commit

Permalink
Simplify buffer source
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Jan 4, 2017
1 parent 72962c0 commit c06ae90
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions rplugin/python3/deoplete/source/buffer.py
Expand Up @@ -26,7 +26,7 @@ def on_event(self, context):
self.__make_cache(context)

def gather_candidates(self, context):
self.__make_cache(context)
self.on_event(context)

same_filetype = context['vars'].get(
'deoplete#buffer#require_same_filetype', True)
Expand All @@ -38,23 +38,12 @@ def gather_candidates(self, context):

def __make_cache(self, context):
try:
if (context['bufnr'] in self.__buffers and
context['event'] != 'BufWritePost' and
len(self.vim.current.buffer) > self.__max_lines):
line = context['position'][1]
buffer = self.__buffers[context['bufnr']]
buffer['candidates'] += parse_buffer_pattern(
getlines(self.vim, max([1, line-500]), line+500),
context['keyword_patterns'],
context['complete_str'])
buffer['candidates'] = list(set(buffer['candidates']))
else:
self.__buffers[context['bufnr']] = {
'filetype': context['filetype'],
'candidates': parse_buffer_pattern(
getlines(self.vim),
context['keyword_patterns'],
context['complete_str'])
}
self.__buffers[context['bufnr']] = {
'filetype': context['filetype'],
'candidates': parse_buffer_pattern(
getlines(self.vim),
context['keyword_patterns'],
context['complete_str'])
}
except UnicodeDecodeError:
return []

0 comments on commit c06ae90

Please sign in to comment.