diff --git a/pythonx/netranger/Vim.py b/pythonx/netranger/Vim.py index d6fc1f9..3b74e66 100644 --- a/pythonx/netranger/Vim.py +++ b/pythonx/netranger/Vim.py @@ -206,11 +206,11 @@ def debug(*msg): def WarningMsg(msg): vim.command( 'unsilent echohl WarningMsg | unsilent echo "{}" | echohl None '. - format(msg.replace('"', '\\"'))) + format(msg.replace('"', '\\"').replace('\\','\\\\'))) def Echo(msg): - vim.command(f'unsilent echo "{msg}"') + vim.command('unsilent echo "%s"' % (msg.replace("\\","\\\\"),)) def UserInput(hint, default=''): diff --git a/pythonx/netranger/netranger.py b/pythonx/netranger/netranger.py index a066cfc..a768e1e 100644 --- a/pythonx/netranger/netranger.py +++ b/pythonx/netranger/netranger.py @@ -2031,8 +2031,10 @@ def _NETRSearchUpdate(self): ignore_case = False if pattern and pattern: - if (Vim.options['smartcase'] and re.match( - '[A-Z]', pattern)) or not Vim.options['ignorecase']: + if (Vim.options['smartcase'] and + re.match("(?=.*[a-z])(?=.*[A-Z])",pattern)) and not Vim.options['ignorecase']: + # if (Vim.options['smartcase'] and re.match( + # '[A-Z]', pattern)) or not Vim.options['ignorecase']: pattern = re.compile('.*' + pattern) else: pattern = re.compile('.*' + pattern, re.IGNORECASE) @@ -2076,6 +2078,26 @@ def _NETRSearchStop(self, accept): # clear command line Vim.command('echo') + def _NETRSearchGTNext(self,forward): + if forward: + accept_line_nr = [n.name for n in self._cur_search_buf.nodes + ].index(Vim.current.line) + 1 + + self._NETRSearchStop(True) + if forward: + nod=self.cur_buf.nodes[accept_line_nr-1] + self.cur_buf._redraw() + self.cur_buf.set_clineno_by_node(nod) + # self.cur_buf.update_nodes_and_redraw(force_redraw=True) + if nod.is_DIR: + self.NETRBufOpen() + self.NETRSearch() + else: + self.NETRParentDir() + self.NETRSearch() + + Vim.command('echo') + def _NETRSearchMove(self, binding): if binding[0] == '<': binding = f'\{binding}>' @@ -2084,6 +2106,7 @@ def _NETRSearchMove(self, binding): def _NETRSearchMap(self): stop_template = 'cnoremap {} python3 ranger._NETRSearchStop({})' move_template = 'cnoremap {} python3 ranger._NETRSearchMove("{}")' + gt_template = 'cnoremap {} python3 ranger._NETRSearchGTNext({})' Vim.command(stop_template.format('', True)) Vim.command(stop_template.format('', False)) Vim.command(stop_template.format('', False)) @@ -2091,6 +2114,8 @@ def _NETRSearchMap(self): Vim.command(move_template.format('', '', '', '',True)) + Vim.command(gt_template.format('',False)) def NETRSearch(self): self._cur_search_buf = self.cur_buf