Skip to content

':LeaderBuffer' Command Fails When Navigating to Deleted Buffers #1107

@yakoye

Description

@yakoye
  • vim or neovim?
    • vim
    • neovim
  • Output of vim --version or nvim --version: VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Nov 13 2024 20:39:13) Included patches: 1-842
  • Output of :echo has("python"): 0
  • Output of :echo has("python3"): 1
  • Output of :echo &pythondll(only vim, not neovim): libpython2.7.so.1.0
  • Output of :echo &pythonthreedll(only vim, not neovim): libpython3.8.so.1.0
  • Output of :py print(sys.version):
  • Output of :py3 print(sys.version): 3.8.10 (default, Jul 29 2024, 17:02:10) [GCC 9.4.0]
  • Output of :echo g:Lf_Debug_Cmd:
  • Output of :echo g:Lf_FilesFromCache:
  • Operating system:
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Configurations related to LeaderF in vimrc:
 let g:Lf_WindowHeight = 0.30
 let g:Lf_HideHelp = 1
 let g:Lf_UseCache = 0
 let g:Lf_UseVersionControlTool = 0
 let g:Lf_IgnoreCurrentBufferName = 1
 let g:Lf_StlColorscheme = 'Powerline'
 let g:Lf_MruEnableFrecency = 1
let g:Lf_PreviewCode = 1
let g:Lf_PreviewResult = {
        \ 'File': 1,
        \ 'Buffer': 1,
        \ 'Mru': 1,
        \ 'Tag': 1,
        \ 'BufTag': 1,
        \ 'Function': 1,
        \ 'Line': 1,
        \ 'Colorscheme': 0,
        \ 'Rg': 1,
        \ 'Gtags': 0
        \}
let g:Lf_WildIgnore = {
    \ 'dir': ['.git', '.hg', '.svn'],
    \ 'file': ['*.o', '*.a', '*.d', '*.i', '*.s', '*.bc', '*.so', '*.pyc', '*.swp', '*.class']
    \ }
let g:Lf_MruWildIgnore = {
    \ 'dir': ['.git', '.hg', '.svn'],
    \ 'file': ['*.o', '*.a', '*.d', '*.i', '*.s', '*.bc', '*.so', '*.pyc', '*.swp', '*.class']
    \}
" If needs
set ambiwidth=double
let g:Lf_StlSeparator = { 'left': "\ue0b0", 'right': "\ue0b2", 'font': "DejaVu Sans Mono for Powerline" }

" LeaderfFile
let g:Lf_ShortcutF = '<C-P>'
noremap <leader>p :LeaderfFile<CR>

noremap <C-L> :LeaderfMru<CR>
noremap <leader>l :LeaderfMru<CR>

"LeaderfBuffer
let g:Lf_ShortcutB = '<C-B>'

let g:Lf_CommandMap = {'<C-K>': ['<Up>'],
                     \ '<C-J>': ['<Down>']}

"noremap <leader>fs :<C-U><C-R>=printf("Leaderf file %s", "")<CR><CR>
"" preview all Line
nnoremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>
"" preview all tag, such as function
nnoremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
"" preview all tag, such as function, more detail
nnoremap <leader>ff :<C-U><C-R>=printf("Leaderf function %s", "")<CR><CR>
noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR>
"noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR>

let g:Lf_RgConfig = [
    \ "--glob=!git/*",
    \ "--glob=!cscope.*",
    \ "--glob=!tags*",
    \ "--hidden"
    \ ]
" search word under cursor, the pattern is treated as regex, and enter
" normal mode directly
nnoremap <C-F> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR>

" search word under cursor literally in all listed buffers
nnoremap <C-D> :<C-U><C-R>=printf("Leaderf! rg --all-buffers -e %s ", expand("<cword>"))<CR>

" search word under cursor literally only in current buffer
nnoremap <leader>gc :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR>

" search visually selected text literally
xnoremap <leader>gf :<C-U><C-R>=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual())<CR>

" recall last search. If the result window is closed, reopen it.
nnoremap <leader>gr :<C-U>Leaderf! rg --recall<CR>

Describe your question, feature request, or bug.

When using the :LeaderBuffer command to open the buffer list, pressing ''' or ' 'to scroll to a buffer file that has been deleted causes an error to occur.

 LeaderF ► Buffer ► FullPath ► /home/hello/code/software/u-boot ►                       ◄ 25/80 ◄ Total: 80
Error detected while processing :
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/hello/vimrc_x/vim/pack/vendor/opt/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1459, in move
AndPreview
    self._previewResult(False)
  File "/home/hello/vimrc_x/vim/pack/vendor/opt/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 446, in _prev
iewResult
    self._previewInPopup(line, self._getInstance().buffer, line_num)
  File "/home/hello/vimrc_x/vim/pack/vendor/opt/LeaderF/autoload/leaderf/python/leaderf/bufExpl.py", line 304, in _prev
iewInPopup
    self._createPopupPreview(vim.buffers[buf_number].name, buf_number, 0, jump_cmd)
  File "/home/hello/vimrc_x/vim/pack/vendor/opt/LeaderF/autoload/leaderf/python/leaderf/utils.py", line 1427, in deco
    return func(self, *args, **kwargs)
  File "/home/hello/vimrc_x/vim/pack/vendor/opt/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1028, in _cre
atePopupPreview
    self._useExistingWindow(title, source, line_num, jump_cmd)
  File "/home/hello/vimrc_x/vim/pack/vendor/opt/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1006, in _use
ExistingWindow
    lfCmd("""call win_execute(%d, '%s')""" % (self._preview_winid, escQuote(jump_cmd)))
vim.error: Vim(normal):E19: Mark has invalid line number
Press ENTER or type command to continue

Steps to reproduce

1. vim open 5 files,don’t close vim
2. :e xx, and Edit multiple lines and stop in the middle,  :w
3. :bp, :bp, :bp, :bp
4. rm xx, from system
5. :LeaderBuffer
6. '<Down>' to xx
7. show error or '<Enter>' show error
### Actual behaviour

### Expected behaviour

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions