Skip to content
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

fix(renderer): check if current buffer is loaded #1406

Merged
merged 4 commits into from Mar 21, 2024

Conversation

pysan3
Copy link
Collaborator

@pysan3 pysan3 commented Mar 20, 2024

          Somehow this commit has caused a bug with `:Neotree current toggle`. 
  1. If you have more than one split,
  2. and you use :Neotree current toggle
  3. then open a file
  4. then :Neotree current toggle
  5. you'll get an error (see below)
  6. then your current window will be closed

Error from step 5:

Error executing vim.schedule lua callback: ...is/.local/share/nvim/lazy/nui.nvim/lua/nui/tree/init.lua:188: missing bufnr                                                     
stack traceback:                                                                                                                                                              
        [C]: in function 'error'                                                                                                                                              
        ...is/.local/share/nvim/lazy/nui.nvim/lua/nui/tree/init.lua:188: in function 'init'                                                                                   
        .../.local/share/nvim/lazy/nui.nvim/lua/nui/object/init.lua:132: in function 'NuiTree'                                                                                
        ...e/chris/repos/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:778: in function 'create_tree'                                                                            
        ...e/chris/repos/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:1190: in function 'draw'                                                                                  
        ...e/chris/repos/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:1326: in function 'show_nodes'                                                                            
        ...ree.nvim/lua/neo-tree/sources/filesystem/lib/fs_scan.lua:96: in function 'render_context'                                                                          
        ...ree.nvim/lua/neo-tree/sources/filesystem/lib/fs_scan.lua:165: in function <...ree.nvim/lua/neo-tree/sources/filesystem/lib/fs_scan.lua:164> 

@pysan3 I'm not sure I am going to be able to debug so I was thinking about reverting it for now. Do you want to look into it before I do?

Originally posted by @cseickel in #1390 (comment)

@cseickel
Copy link
Contributor

Sorry, I still have the same problem. I'll try to file a proper bug report with a minimal config tomorrow.

@pysan3
Copy link
Collaborator Author

pysan3 commented Mar 20, 2024

Did you pull the right branch?

{
  "pysan3/neo-tree.nvim",
  branch = "fix-check-buf-available",
  ...

If you are using lazy, double check in the UI. Changing the repo nvim-neo-tree to pysan3 might not be detected and still tries to pull from nvim-neo-tree.

I cannot reproduce it anymore...

@cseickel
Copy link
Contributor

If you are using lazy, double check in the UI. Changing the repo nvim-neo-tree to pysan3 might not be detected and still tries to pull from nvim-neo-tree.

My lazy config always points to my local folder and that is definitely on this PR. I confirmed that by adding a log statement in my local repo.

@pysan3
Copy link
Collaborator Author

pysan3 commented Mar 20, 2024

@cseickel is the error message exactly the same?

@cseickel
Copy link
Contributor

@cseickel is the error message exactly the same?

Yes:

Error executing vim.schedule lua callback: ...is/.local/share/nvim/lazy/nui.nvim/lua/nui/tree/init.lua:188: missing bufnr                                                     
stack traceback:                                                                                                                                                              
        [C]: in function 'error'                                                                                                                                              
        ...is/.local/share/nvim/lazy/nui.nvim/lua/nui/tree/init.lua:188: in function 'init'                                                                                   
        .../.local/share/nvim/lazy/nui.nvim/lua/nui/object/init.lua:132: in function 'NuiTree'                                                                                
        ...e/chris/repos/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:778: in function 'create_tree'                                                                            
        ...e/chris/repos/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:1190: in function 'draw'                                                                                  
        ...e/chris/repos/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:1326: in function 'show_nodes'                                                                            
        ...ree.nvim/lua/neo-tree/sources/filesystem/lib/fs_scan.lua:96: in function 'render_context'                                                                          
        ...ree.nvim/lua/neo-tree/sources/filesystem/lib/fs_scan.lua:165: in function <...ree.nvim/lua/neo-tree/sources/filesystem/lib/fs_scan.lua:164> 

@pysan3
Copy link
Collaborator Author

pysan3 commented Mar 20, 2024

😭

Ok please revert the PR. I don't have time right now.

@pysan3
Copy link
Collaborator Author

pysan3 commented Mar 20, 2024

@cseickel Added one more fix. Could you pull the latest commit and test it again?

@cseickel
Copy link
Contributor

See #1408

@cseickel cseickel closed this Mar 20, 2024
@pysan3
Copy link
Collaborator Author

pysan3 commented Mar 21, 2024

@cseickel Did you check if this PR fixes the issue instead? Your fix should not work with vsplit as I explained.

That one may work sometimes due to timing issues but that's just because you were lucky. Please test it a couple of times.

@cseickel
Copy link
Contributor

I did try this PR, even after your last fix, and it has no effect at all. I still get the error every single time. I also get errors with this branch every time I am using a float and try to open a file where there is no valid window to reuse at ground.

With my fix, which is actually just reverting the close window code back to what it has always been, all situations work as expected and no matter how many times I do it, I can't create any error.

@pysan3
Copy link
Collaborator Author

pysan3 commented Mar 21, 2024

Could you record what you are seeing?

If your record is too big in size to be uploaded, please use this ffmpeg script to reduce the size. This will create ./record.mp4 in cwd.

ffmpeg -i <INPUT-FILE> \
  -vf "fps=10,scale=1080:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
  -pix_fmt yuv420p \
  -loop 0 record.mp4 -y
  • cd /path/to/neo-tree.nvim
  • nvim --version
  • nvim
  • :e README.md
  • :vs release.sh
  • :Neotree current toggle
  • choose any file
  • :Neotree current toggle
  • choose any file
  • :Neotree current toggle
  • q (quit without selecting)
  • :Neotree current toggle
  • <C-w>h (go to left window)
  • :Neotree current toggle
  • choose any file
  • :Neotree current toggle
  • choose any file
  • :Neotree current toggle
  • q (quit without selecting)
  • :Neotree current toggle
record.mp4

As you can see in this recording, I have no problem with this PR.

@pysan3
Copy link
Collaborator Author

pysan3 commented Mar 21, 2024

@cseickel

@pysan3
Copy link
Collaborator Author

pysan3 commented Mar 21, 2024

There's one more commit I pushed to this branch but it looks like it's not been updated.

@cseickel I think if you pull right now, please check you are on commit 934935a704d414b09f4cd088f085eac517db4943 don't close buffer when toggled on.

@cseickel
Copy link
Contributor

There's one more commit I pushed to this branch but it looks like it's not been updated.

@cseickel I think if you pull right now, please check you are on commit 934935a704d414b09f4cd088f085eac517db4943 don't close buffer when toggled on.

That is better. The latest commit seems to handle all situations. I'm going to reopen this...

@cseickel cseickel reopened this Mar 21, 2024
@pysan3
Copy link
Collaborator Author

pysan3 commented Mar 21, 2024

Please revert your PR before merging this or this code will not work as intended.

@cseickel
Copy link
Contributor

Please revert your PR before merging this or this code will be completely broken.

No need, I merged it properly.

@cseickel cseickel merged commit 16d1b19 into nvim-neo-tree:main Mar 21, 2024
2 checks passed
@pysan3 pysan3 deleted the fix-check-buf-available branch March 21, 2024 23:42
@ttytm
Copy link
Contributor

ttytm commented Mar 25, 2024

The commit unfortunately comes with a regression for me. Without having looked into it deepl somewhat interferes with the sign- / statuscol.

Spacing left to the nodes without the commit:
Screenshot_20240325_144920

Spacing after the commit:

Screenshot_20240325_144920

@pysan3
Copy link
Collaborator Author

pysan3 commented Mar 25, 2024

@ttytm Thanks for reporting and sorry about the experience.

Could you open a new issue with your config? Please ping me there and I'll look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants