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

Prevent pfiletype from failing when bufname is nil #2531

Merged
merged 2 commits into from
May 24, 2023

Conversation

pijusn
Copy link
Contributor

@pijusn pijusn commented May 24, 2023

Description

This is fixing an issue introduced in this commit.

A fresh install of NvChad fails with following error:

Error executing vim.schedule lua callback: ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:428: Error executing lua: ...al/share/nvim/lazy/plenary.nvim/lua/plenary/filetype.lua:55: attempt to index l
ocal 'filename' (a nil value)
stack traceback:
        ...al/share/nvim/lazy/plenary.nvim/lua/plenary/filetype.lua:55: in function '_get_extension_parts'
        ...al/share/nvim/lazy/plenary.nvim/lua/plenary/filetype.lua:103: in function 'detect_from_extension'
        ...al/share/nvim/lazy/plenary.nvim/lua/plenary/filetype.lua:168: in function 'detect'
        ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:434: in function <...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:428>
        [C]: in function 'nvim_buf_call'
        ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:428: in function <...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:422>
stack traceback:
        [C]: in function 'nvim_buf_call'
        ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:428: in function <...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:422>

Maybe there is a cleaner way to do this but this is a quick and defensive solution to the problem. If you want to fix it differently, it's OK.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

To reproduce it:

  1. Setup a fresh NvChad install.
  2. Run nvim.
  3. Wait for Lazy to install the plugins (it takes latest of telescope.nvim).
  4. Quit the editor, as instructed.
  5. Run nvim.
  6. Type <leader>th to open theme editor (it runs buffer_previewer logic).
  7. 💥

Configuration:

NVIM v0.9.0
Build type: Release
LuaJIT 2.1.0-beta3
MacOS 13.2.1

@pijusn
Copy link
Contributor Author

pijusn commented May 24, 2023

@akinsho you might have the necessary context to decide whether this patch or a different change is more appropriate.

@Conni2461
Copy link
Member

thanks :) can you fix stylua ci after that i would merge

@Conni2461
Copy link
Member

thanks :)

@Conni2461 Conni2461 merged commit 109a183 into nvim-telescope:master May 24, 2023
abelmul pushed a commit to abelmul/telescope.nvim that referenced this pull request Jun 6, 2023
…pe#2531)

* Prevent pfiletype from failing when bufname is nil

* Fix code style
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.

2 participants