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(popup): set modifiable failed when vim.api.nvim_buf_set_lines #575

Merged
merged 12 commits into from
Apr 25, 2024

Conversation

AlejandroSuero
Copy link
Contributor

In the commit 0d0079c, I introduced a bug (sorry).

To reproduce:

:set nomodifiable
-- or
:lua vim.o.modifiable = false
-- and
:Telescope find_files

Note

I used Telescope cmdline in the demo bellow, but it will apply to any plugin using popup.create

Bug:

Telescope cmdline not launching Telescope cmdline not displaying items

Note

It will launch the popup but it won't fill it

After the changes:

Telecope cmdline working correctly
========================================
Testing:        /Users/aome/dev/nvim_plugins/plenary.nvim/tests/plenary/popup_spec.lua
Success ||      plenary.popup can create a very simple window
Success ||      plenary.popup can create a very simple window after 'set nomodifiable'
Success ||      plenary.popup can apply a highlight
Success ||      plenary.popup can create a border
Success ||      plenary.popup can apply a border highlight
Success ||      plenary.popup can ignore border highlight with no border
Success ||      plenary.popup can do basic padding
Success ||      plenary.popup can do padding and border
Success ||      plenary.popup borderchars can support multiple border patterns
Success ||      plenary.popup borderchars can support multiple patterns inside the borderchars
Success ||      plenary.popup what can be an existing bufnr
Pending ||      plenary.popup cursor not yet tested

Success:        11
Failed :        0
Errors :        0
========================================

feat: added test for `set nomodifiable`

fix(popup): set modifiable regardless

fix(popup): set modifiable globally

fix(popup): set modifiable first

fix(popup): added modifiable is false check
@Conni2461
Copy link
Collaborator

Conni2461 commented Apr 24, 2024

the change looks super where, can you rebase this branch

image

because on your branch i cant find the original change, but its also not dropped in the changes. so i have no idea whats currently going on, other than the change doesnt look "correct".

The right image shows the current HEAD while the left side shows the diff from this PR

@AlejandroSuero
Copy link
Contributor Author

@Conni2461 now it should show the changes correctly. Didn't notice that the branch was not showing the changes completely, sorry 😅

Comment on lines 118 to 120
if vim.o.modifiable == false then
vim.o.modifiable = true
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

this just enables this globally. change this setting, we probably dont want this?!

@AlejandroSuero
Copy link
Contributor Author

@Conni2461 I made the changes, kept it like the master branch and added the check in lua/plenary/window/border.lua because the error said that it was failing at line 219.

Now it works, but doesn't render the preview on the files. Don't know the reason.

plenary-feat-modifiable-popup.mp4

@Conni2461
Copy link
Collaborator

Now it works, but doesn't render the preview on the files. Don't know the reason.

this is a telescope issue, telescope creates the buffers for the file previewer. so we need to fix it here: https://github.com/nvim-telescope/telescope.nvim/blob/master/lua/telescope/previewers/buffer_previewer.lua#L428

also why dont we do vim.api.nvim_buf_set_option(self.bufnr, "modifiable", true) unconditionally? it always needs to be true, regardless of what vim.o.modifiable is

AlejandroSuero added a commit to AlejandroSuero/telescope.nvim that referenced this pull request Apr 25, 2024
Not showing a preview with the new changes in the latest changes of
[plenary.nvim PR
nvim-telescope#575](nvim-lua/plenary.nvim#575).

The error occurs when changing from `nomodifiable` to `modifiable`.
Telescope itself works, but the previews don't render.
@AlejandroSuero
Copy link
Contributor Author

With the changes made in this PR and in telescope.nvim#3077 now it works perfectly.

Telescope find_files rendering preview after set nomodifiable

@Conni2461 Conni2461 merged commit 08e3019 into nvim-lua:master Apr 25, 2024
6 checks passed
@Conni2461
Copy link
Collaborator

thanks :)

Conni2461 pushed a commit to nvim-telescope/telescope.nvim that referenced this pull request Apr 25, 2024
)

Not showing a preview with the new changes in the latest changes of
[plenary.nvim PR
#575](nvim-lua/plenary.nvim#575).

The error occurs when changing from `nomodifiable` to `modifiable`.
Telescope itself works, but the previews don't render.
@AlejandroSuero AlejandroSuero deleted the feat-set-modifiable-popup branch April 26, 2024 00:14
Conni2461 pushed a commit to nvim-telescope/telescope.nvim that referenced this pull request May 20, 2024
)

Not showing a preview with the new changes in the latest changes of
[plenary.nvim PR
#575](nvim-lua/plenary.nvim#575).

The error occurs when changing from `nomodifiable` to `modifiable`.
Telescope itself works, but the previews don't render.

(cherry picked from commit 1084d07)
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

2 participants