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: enable_preview true #3097

Conversation

MovieMaker93
Copy link
Contributor

Description

This fix aims to resolve the issue about the "enable_preview" feature that wasn't working.
Now if you call:
:Telescope colorscheme enable_preview=true
while scrolling through the different color scheme options, the live preview is working (change color scheme accordingly)

Fixes #2966

Type of change

Please delete options that are not relevant.

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

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration

I tried two different scenarios:

  • :Telescope colorscheme enable_preview=true --> When scrolling through the different color schemes, the theme changes accordingly
  • :Telescope colorscheme enable_preview=false --> When scrolling through the different color schemes, the theme doesn't change

Configuration:

  • Neovim version (nvim --version): 0.9.4
  • Operating system and version: ubuntu 22.04

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

Copy link
Contributor

@jamestrew jamestrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the existing changes look good.
One thing I forgot to mention about that we should clean up is the existing code to set the previewer.

I think the if vim.fn.buflisted(bufnr) ~= 1 ... part of the code path was a prior attempt to enable previews without a previewer, but it either never worked or no longer works. So we can just completely remove this part. It should be redundant now either way. You can also probably remove the vim.cmd.colorscheme(entry.value) inside the define_preview function in the new_buffer_previewer block as well as it's also redundant now.

@MovieMaker93
Copy link
Contributor Author

I think the existing changes look good. One thing I forgot to mention about that we should clean up is the existing code to set the previewer.

I think the if vim.fn.buflisted(bufnr) ~= 1 ... part of the code path was a prior attempt to enable previews without a previewer, but it either never worked or no longer works. So we can just completely remove this part. It should be redundant now either way. You can also probably remove the vim.cmd.colorscheme(entry.value) inside the define_preview function in the new_buffer_previewer block as well as it's also redundant now.

Okay, thanks for the feedback. I've removed both the vim.fn.buflisted check and the cmd.colorscheme command. In addition, just to be sure, I've tested it again, and it seems to work fine. Let me know if everything is correct on your end.

@jamestrew jamestrew merged commit 9661012 into nvim-telescope:master May 17, 2024
9 checks passed
@jamestrew
Copy link
Contributor

Thanks! Looks good and works for me as well.

@jamestrew jamestrew added the backport-0.1.x PR to be backported to 0.1.x (Neovim 0.7 compat) label May 17, 2024
Conni2461 pushed a commit that referenced this pull request May 20, 2024
* fix: enable_preview true

* fix: remove buflisted check and colorscheme command in the buffer previewer

---------

Co-authored-by: nobrain <moviemaker@alfonso>
(cherry picked from commit 9661012)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-0.1.x PR to be backported to 0.1.x (Neovim 0.7 compat)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding a previewer option to colorscheme picker
2 participants