Ejemplo n.º 1
0
    def _jump(self, context: UserContext, target: Candidate) -> None:
        if 'action__pattern' in target:
            self.vim.call('search', target['action__pattern'], 'w')

        line = int(target.get('action__line', 0))
        col = int(target.get('action__col', 0))

        try:
            if line > 0:
                self.vim.call('cursor', [line, 0])
                if 'action__col' not in target:
                    pos = self.vim.current.line.lower().find(
                        context['input'].lower())
                    if pos >= 0:
                        self.vim.call('cursor', [0, pos + 1])
            if col > 0:
                self.vim.call('cursor', [0, col])
            elif context['input']:
                # Search input
                self.vim.call('cursor', [line, 1])
                self.vim.call('search', context['input'], 'W', line)
        except Exception:
            pass

        # Open folds and centering
        self.vim.command('normal! zv')
        self.vim.command('normal! zz')
Ejemplo n.º 2
0
 def _highlight(self, context: UserContext, target: Candidate) -> None:
     util.clearmatch(self.vim)
     if 'action__pattern' in target:
         self.vim.current.window.vars['denite_match_id'] = self.vim.call(
             'matchadd', context['highlight_preview_line'],
             target['action__pattern'])
     else:
         line = int(target.get('action__line', 0))
         self.vim.current.window.vars['denite_match_id'] = self.vim.call(
             'matchaddpos', context['highlight_preview_line'], [line])