Yggdroot / LeaderF

An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly for both vim and neovim.
Apache License 2.0
2.14k stars 180 forks source link

5ad91dc is causing error #1050

Closed yangrq1018 closed 7 months ago

yangrq1018 commented 7 months ago

Describe your question, feature request, or bug.

Leader f rg is printing python exception on selection.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/martin/LeaderF/autoload/leaderf/python/leaderf/anyExpl.py", line
 821, in start
    the_args.start(arguments, *args, **kwargs)
  File "/home/martin/LeaderF/autoload/leaderf/python/leaderf/anyExpl.py", line
 753, in _default_action
    manager.startExplorer(win_pos[2:], *args, **kwargs)
  File "/home/martin/LeaderF/autoload/leaderf/python/leaderf/rgExpl.py", line
1137, in startExplorer
    super(RgExplManager, self).startExplorer(win_pos, *args, **kwargs)
  File "/home/martin/LeaderF/autoload/leaderf/python/leaderf/manager.py", line
 2799, in startExplorer
    self.input()
  File "/home/martin/LeaderF/autoload/leaderf/python/leaderf/manager.py", line
 62, in deco
    func(self, *args, **kwargs)
  File "/home/martin/LeaderF/autoload/leaderf/python/leaderf/manager.py", line
 3080, in input
    if self.accept() is None:
       ^^^^^^^^^^^^^
  File "/home/martin/LeaderF/autoload/leaderf/python/leaderf/manager.py", line
 2373, in accept
    self._accept(file, mode, self._getInstance().buffer, line_num) # for bufTa
g
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/LeaderF/autoload/leaderf/python/leaderf/utils.py", line 1
419, in deco
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/LeaderF/autoload/leaderf/python/leaderf/manager.py", line
 2264, in _accept
    self._acceptSelection(file, *args, **kwargs)
  File "/home/martin/LeaderF/autoload/leaderf/python/leaderf/rgExpl.py", line
20, in deco
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Steps to reproduce

Use leader f rg search, type something to search for, choose any entry from the result, hit enter, then the error logging shows up.

The jump is fine, though. Dismiss the error then we can jump to that file.

Actual behaviour

See above.

Expected behaviour

Select the result should not print any error.

yangrq1018 commented 7 months ago
diff --git a/autoload/leaderf/python/leaderf/rgExpl.py b/autoload/leaderf/python/leaderf/rgExpl.py
index bc23f61..7f7ba80 100644
--- a/autoload/leaderf/python/leaderf/rgExpl.py
+++ b/autoload/leaderf/python/leaderf/rgExpl.py
@@ -594,6 +594,7 @@ class RgExplManager(Manager):
             else:
                 lfCmd("hide buffer +%s %s" % (line_num, buf_number))
             lfCmd("norm! ^zv")
+            lfCmd("call search('%s', 'zW', line('.'))" % escQuote(self._getExplorer().getPatternRegex()[0]))
             lfCmd("norm! zz")

             if "preview" not in kwargs:

This is definitely causing the issue. getPatternRegex() returns nothing.

Yggdroot commented 7 months ago

Fixed, thanks.

yangrq1018 commented 7 months ago

Fixed.