Skip to content

Commit

Permalink
Fix context error in sources
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Jun 6, 2021
1 parent 2a23e92 commit 218229c
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions rplugin/python3/deoplete/child.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ def _get_result(self, context: UserContext,
if ctx['max_menu_width'] > 0:
ctx['max_menu_width'] = max(10, ctx['max_menu_width'])

self._set_context_case(source, ctx)

# Gathering
self._profile_start(ctx, source.name)
ctx['vars'] = self._vim.vars
Expand Down Expand Up @@ -300,6 +302,19 @@ def _gather_async_results(self, result: Result,
except Exception as exc:
self._handle_source_exception(source, exc)

def _set_context_case(self, source: typing.Any,
context: UserContext) -> None:
case = source.smart_case or source.camel_case
ignorecase = source.ignore_case
if case:
if re.search(r'[A-Z]', context['complete_str']):
ignorecase = False
else:
ignorecase = True
context['camelcase'] = source.camel_case
context['ignorecase'] = ignorecase
context['smartcase'] = source.smart_case

def _handle_source_exception(self,
source: typing.Any, exc: Exception) -> None:
if isinstance(exc, SourceInitError):
Expand Down Expand Up @@ -359,17 +374,7 @@ def _get_candidates(self, result: Result,
ctx['complete_str'] = context_input[ctx['char_position']:]
ctx['is_sorted'] = False

# Set ignorecase
case = source.smart_case or source.camel_case
ignorecase = source.ignore_case
if case:
if re.search(r'[A-Z]', ctx['complete_str']):
ignorecase = False
else:
ignorecase = True
ctx['camelcase'] = source.camel_case
ctx['ignorecase'] = ignorecase
ctx['smartcase'] = source.smart_case
self._set_context_case(source, ctx)

# Match
matchers = [self._filters[x] for x
Expand Down Expand Up @@ -410,8 +415,6 @@ def _get_candidates(self, result: Result,
for candidates in sorted_candidates:
ctx['candidates'] += candidates

ctx['ignorecase'] = ignorecase

# On post filter
if hasattr(source, 'on_post_filter'):
ctx['candidates'] = source.on_post_filter(ctx)
Expand Down

0 comments on commit 218229c

Please sign in to comment.