-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<Leader>bs
shows the wrong buffer… sometimes
#120
Comments
I'm sorry to hear about this frustrating intermittent problem. You mention running 7.5.0 now, where you are seeing the problem. Do you have an idea which version of BufExplorer you were using in the past before you first encountered this issue? You might be able to narrow things down by running that older version of BufExplorer for a while to verify that the issue doesn't occur, rather than trying to revert your ALE and YouCompleteMe changes. There still could be some interaction between the plugins, but having a smaller range of BufExplorer versions to consider would be helpful. Visiting the wrong buffer when pressing bufexplorer/plugin/bufexplorer.vim Line 802 in 13a64f2
When pressing let _bufNbr = str2nr(getline('.')) The current line in the BufExplorer window is retrieved and converted to a number. Vim's :echo str2nr(' 33u home.html /path/....') In the usual case, the flow picks up with line 882. In your scenario with only a single tab open and with One way to verify how may tabs are open is to echo the last tab number (which is also the number of open tabs): :echo tabpagenr('$') But I'm assuming you indeed had only the one tab open during your tests. For the case of opening into another tab, I wonder whether you might have pressed shift- When you next encounter the issue, it might help to ensure you have only one tab open, then close all but one window and use |
@drmikehenry: I appreciate your thoughtful reply. My best guess for which version of Bufexplorer I was using, before I first noticed this issue, would be either 7.4.23 or 7.4.26. (I started working on a new project early-to-mid 2023, using tech I hadn't used in a while, and that's when I usually update my tools and scripts.) Looking at the release notes since then, and from your description of OTOH, it's quite conceivable that I accidentally pressed Shift+Enter at some point, given that the right Shift key sits right below Enter on my keyboard. I might even be able to blame the cat for that. 🙀 Thanks for that insight. BTW, can you please tell me how you link to a line of code in a GitHub comment like that? I often want to do it but have never found a way, and your comment is somehow the first where I've seen it done. |
One idea for getting a little more information is to use the below script to watch Vim's autocommands. Save this script as function! Bufx_log(msg)
call writefile([a:msg], '/tmp/bufx.log', 'a')
endfunction
function! Bufx_record(cmd)
let bufNbr = expand('<abuf>')
let winNbr = winnr()
let tabNbr = tabpagenr()
let name = expand('<afile>')
let numWindows = winnr('$')
call Bufx_log(printf('%-12s %3s, %3s, %3s, #win=%2d, «%s»',
\ a:cmd, bufNbr, winNbr, tabNbr, numWindows, name))
endfunction
augroup Bufx
autocmd!
autocmd BufNew * call Bufx_record('BufNew')
autocmd BufEnter * call Bufx_record('BufEnter')
autocmd BufDelete * call Bufx_record('BufDelete')
autocmd BufWipeout * call Bufx_record('BufWipeout')
autocmd WinEnter * call Bufx_record('WinEnter')
autocmd WinLeave * call Bufx_log('') | call Bufx_record('WinLeave')
autocmd TabNew * call Bufx_record('TabNew')
autocmd TabEnter * call Bufx_record('TabEnter')
autocmd TabLeave * call Bufx_record('TabLeave')
autocmd TabClosed * call Bufx_record('TabClosed')
augroup END This script may be sourced at any time in a running Vim instance via: :source bufx.vim It creates a log file recording the comings and goings of buffers, windows, and tabs. The columns in the log file are:
It's got a hard-coded path to the log file ( After sourcing, below is the output from launching BufExplorer via
When you next encounter the issue, you can source this script and then watch the log file as you trigger the issue. If there's some weird interaction with other plugins, perhaps you'll be able to see something interesting in the logs (e.g., a You could also patch the I endorse the time-honored approach of blaming the cat! :-) Github has a "permalink" feature for linking into code. To make a permalink:
You can optionally choose a different branch or tag before navigating to the file and line number. Only after typing the above did I think to hunt up a reference: https://github.com/github/docs/blob/main/content/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet.md |
I've been using and loving Bufexplorer for well over 15 years, but in recent months, it's sometimes opened a buffer other than the one I selected. This happens maybe once or twice a week, and I've always just quit gVim and started a new session to work around it.
I haven't filed an issue before now, because, unfortunately, I don't have a reliable set of steps for making it happen. But I can reproduce the issue in my gVim session right now. I'm hoping that, if I tell you about my setup and what's changed, you could suggest things to try, to see whether I can reproduce it more reliably.
I started this gVim session a few hours ago, using a Bash script that loads 26 files. Honestly, I wrote the script because of this bug; I always made heavy use of
:mksession
s, but having a clean starting point of frequently needed files for this project has been pretty useful, too. Anyhow, I've been using Bufexplorer and other tools during this session without issue, until now. Now, when I type\bs
(\
being my Leader), I see 27 buffers, the highest number being 33, because I've loaded a few other files and deleted them (d
) in Bufexplorer. That's all good, except that, consistently, when I move the cursor to buffer 33, a file called 'home.html', and type Enter, it instead loads buffer 4, one of the 'urls.py' files that I've also been editing.When I first noticed this issue today, I had my session split into four windows, and I was trying to use
\bs
to open a fifth. I closed most of the windows with:q
, and used\be
to load various other files, all of which loaded correctly. Still, when I try to load the file I want, 'home.html', it loads that 'urls.py' instead. Strangely, 'home.html' is listed with the%a
attributes, but I'm pretty sure I never actually had it open. The relevant 'urls.py' is also listed as active, i.e. witha
.One thing I did that might have confused Bufexplorer this time is that previously, for 'home.html', file, I used
:file
and:w
to create a copy of the file under a new name. I've had this issue come up without me having done that, though, so this may be a red herring. I've also done this many times over the years without Bufexplorer acting up, but maybe this is a new bug, or something related to a newly installed plug-in.When I've previously noticed this issue, once or twice I found that the buffer I wanted was actually being loaded into another tab. I've never used tabs in gVim, so it may have happened more often than that without me noticing. There are no tabs visible now, though. I recently disabled the menu bar in my
.vimrc
, but even when I make it appear again now, withset guioptions+=m
, still no tabs appear.I'm using bufexplorer 7.5.0 (so #117, which seemed vaguely related, should be fixed?) under gVim 9.1. I was also experiencing this issue under gVim 8.2. My OS is Linux Mint 21.3 Cinnamon.
These are the other plug-ins I have installed:
I've installed the bottom three pretty recently, but after I started noticing this issue. I've used most of the rest since well before I started noticing this issue. However, I've made a lot of changes to my ALE setup (
dense-analysis/ale
) and YouCompleteMe in recent months. I honestly can't remember whether this issue started happening before I started making those changes, and since this issue occurs fairly seldomly, even if I revert those changes today, it'd take a week or two of this issue not occurring, to convince myself that they're related. And then it would open the whole can of worms for which changes are causing the problem.But if you can think of things to try that might reproduce the issue more quickly, I could give it a go and let you know.
Sorry this is so vague.
The text was updated successfully, but these errors were encountered: