Closed kyoh86 closed 3 years ago
I tried a few different things, and I can't really reproduce your problem with your steps, including when I use a simple basic vimrc 🤔
What is your switchbuf
setting? Or maybe there is another setting that affects this?
I tried your patch, and both :buf
and :sbuf
seem to behave the same to me; I don't really recall why I used :sbuf
over :buf
; perhaps there is no good reason for it, but it would be good to know in which cases exactly it fails/doesn't work.
Ah wait, I see that with set hidden
I can reproduce it.
I can't see any downsides from merging your patch; and if some crop up we can deal with them as-needed.
Thank you :-)
Actually, I have just discovered a problem with this change when looking at your other issue (#45):
$ vim a.go
:split b.go
:GoCoverage
And now only one window is highlighted, instead of all of them.
Similar if you use :tabedit
.
Not sure how I missed this is my testing earlier; I think I mixed up which version I was testing in between playing around with all the settings 😅
If I revert back to :sbuf
it works as expected. I reverted your PR for now, sorry. I'm not sure what to do about this, but a good start would be to write some better tests for this.
The idea is that gopher#buf#doall()
will do some work on all buffers without UI side-effects; I don't use that in gopher.vim because it doesn't work for some reason. I'll have a look at fixing that, which should simply eliminate the need from calling buf
or sbuf
here entirely.
All of this stuff is pretty complicated/confusing.
Okay, I figured it out: functions such as getmatches()
and matchadd()
add matches to the current window; this is why using <n>bufdo [..]
(via gopher#buf#doall()
) doesn't work.
And this is also why it uses :sbuf
and sets switchbuf=useopen,usetab,newtab
: it needs to set the active window for all buffers.
matchadd()
and clearmatches()
now allow setting a windowID in the options dict; this was added in Vim 8.1.1084 (after I wrote this) and we can probably use that now.
Possible fix in #47; which should be in right direction. There is a still a problem with tabs I need to figure out. You can try it out and let me know if you find any problems.
Sorry for the many notifications 😅
@arp242 Thank you!
And now only one window is highlighted, instead of all of them.
operate on windows, not buffers
oh I see. I will try #47!
:edit a.go
):edit b.go
):GoCoverage
Why
:GoCoverage
usessbuf
to open that buffer in new window? When many buffers exist,:GoCoverage
shows many windows. They're obstacles.