You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reason, at this point, b:dirvish is not set, so it ends up calling :Dirvish a second time, this time with the directory name as the argument.
We again go through dirvish#open(), s:open_dir(), s:should_reload(), but this time the line count is > 1000 and the buffer is non-empty, so we hit this else branch and return 0.
So, I don't really know how all this is supposed to work. But the repeat call to dirvish#open() is why we see the (probably unwanted) "showing cached listing" message.
If I hard-code s:should_reload() to return 1, I don't see the "cached listing" message, and the appropriate file (0500.txt) gets selected in the view. Likewise if I increase the size limit above 1000 (or if I delete some files to get below the 1000-file limit).
Although this repro describes the initial open, I see similar behavior for subsequent opens too. For example, if I open another file with :e 0700.txt and then hit -, whatever file was previously selected in Dirvish will still be selected. (For the same reason, if I open a file using Dirvish — ie not with :e but by hitting <CR> when the file is selected in Dirvish — then it continues to be selected when I hit -).
Not sure what the right solution is here. A quick hack is to raise the hard-coded limit. Another idea would be to make it configurable via variable. You might also consider just always reloading, as it seems quite fast (and correct is better than fast). On the other hand, the fact that it is calling dirvish#open() twice in a row due to the autocmd sounds like a bit of a smell, but I am not sure how to fix that.
The text was updated successfully, but these errors were encountered:
You might also consider just always reloading, as it seems quite fast (and correct is better than fast).
yeah I suppose so. The thought was that it could be unpleasant when navigating around, to constantly reload a listing from the fs. Though I suppose the fs cache should take care of that....
On the other hand, the fact that it is calling dirvish#open() twice in a row due to the autocmd sounds like a bit of a smell
should be harmless unless it's reloading the whole listing, but I don't think that's the case. #open() is the entrypoint and has multiple "modes". This is how Dirvish reuses buffers (and all the state implied there , including cursor position)
Repro
ie. open vim in a directory with > 1000 files and open a file somewhere in the middle.
Now hit the
-
binding for vim-dirvish.Expected behavior
Actual behavior
dirvish: showing cached listing ("R" to reload)
Variations
Analysis
Not super familiar with the code base, but this is what seems to be happening:
Dirvish
command with the name of the current file (%:p
).dirvish#open()
dirvish#open
callss:open_dir()
, forwarding along the current file name.s:open_dir()
checks whether its:should_reload()
.s:should_reload()
returns1
.BufEnter
autocommand runs.b:dirvish
is not set, so it ends up calling:Dirvish
a second time, this time with the directory name as the argument.dirvish#open()
,s:open_dir()
,s:should_reload()
, but this time the line count is > 1000 and the buffer is non-empty, so we hit thiselse
branch and return0
.So, I don't really know how all this is supposed to work. But the repeat call to
dirvish#open()
is why we see the (probably unwanted) "showing cached listing" message.If I hard-code
s:should_reload()
to return 1, I don't see the "cached listing" message, and the appropriate file (0500.txt) gets selected in the view. Likewise if I increase the size limit above 1000 (or if I delete some files to get below the 1000-file limit).Although this repro describes the initial open, I see similar behavior for subsequent opens too. For example, if I open another file with
:e 0700.txt
and then hit-
, whatever file was previously selected in Dirvish will still be selected. (For the same reason, if I open a file using Dirvish — ie not with:e
but by hitting<CR>
when the file is selected in Dirvish — then it continues to be selected when I hit-
).Not sure what the right solution is here. A quick hack is to raise the hard-coded limit. Another idea would be to make it configurable via variable. You might also consider just always reloading, as it seems quite fast (and correct is better than fast). On the other hand, the fact that it is calling
dirvish#open()
twice in a row due to theautocmd
sounds like a bit of a smell, but I am not sure how to fix that.The text was updated successfully, but these errors were encountered: