current_buffer_fuzzy_find changes buffer after selecting entry from picker
Description
When running the builtin current_buffer_fuzzy_find, searching and selecting an entry from the picker, the current buffer gets changed.
I have a markdown file open and set the right line limit to 80, inserting hard breaks if longer. Certain lines which are automatically broken I manually re-join eg. links which look weird when automatically broken, basically to read pleasantly to the eye.
However when using :Telescope current_buffer_fuzzy_find, entering a search term which matches on such an overlong line, selecting the match with <CR>, the buffer is altered and the overlong line gets formatted as if I would type qwap. This is very annoying as I have to type u to undo the buffer change.
Is there a configuration setting to prevent telescope from altering the buffer? Is this a bug / expected behavior?
Neovim version
NVIM v0.6.0-dev+518-g1dbbaf89b
Operating system and version
Windows 10
checkhealth telescope
I have no rg installed so `:checkhealth telescope` errors, but this should be totally unrelated?
Steps to reproduce
Set textwidth to eg 70
Enter long text
manually join J overlong line together
search using current_buffer_fuzzy_find for an occurrence in that line, select the hit
the manually joined line gets split again
Expected behavior
Buffer where is within remains unchanged
Actual behavior
Buffer is changed
Minimal config
Telescope and plenary package loaded. No change to any defaults
Its not expected behavior but i also cant reproduce. Mind sharing a video :laughing:
I am also interested in the checkhealth error you mentioned.
I can't record in Windows but I could further narrow down the problem:
- When I open the picker and do not type but chose a matching entry with <Up> or <Down> and press enter, the buffer is not changed.
- When I type characters to match (I am then in insert mode in picker) and press <ESC> and press then <CR>, the buffer remains unchanged.
- Only if I open the picker, start typing characters and then either press <CR> immediately or refine the match by further narrowing down with <UP> or <Down>, the buffer gets changed.
Unfortunately this is by far my most frequent use of current_buffer_fuzzy_find changes
I just discovered that the behavior is the same in Windows or Linux.
This is the minimum to replicate the error:
-
Open nvim
-
set
:set fo=atnqw:set tw=70 -
Type some random words, wait for the line to break automatically.
-
Go to line 1, manually join 'J' with the automatically broken line 2
-
run
:Telescope current_buffer_fuzzy_find -
Type any string pattern which can be found on the line in the buffer
-
hit
<CR> -
See the line split again
Okay thanks. I did manage to reproduce it. This happens for me if set fo+=a is set. Dont even need to set tw.
a Automatic formatting of paragraphs. Every time text is inserted or
deleted the paragraph will be reformatted. See |auto-format|.
When the 'c' flag is present this only happens for recognized
comments.
So this matches what you said in your last finding
Only if I open the picker, start typing characters and then either press immediately or refine the match by further narrowing down with or , the buffer gets changed.
Because we insert text. I tried removing this option on telescope open and appending it on telescope close. But it didnt help. I also tried to remove it for only our buffers, also didnt work. But i also have to admit. I have no prior knowledge about formatoptions.
Well if I press ESC prior to selecting with CR (so leaving insert mode on the picker), the buffer is not altered. Maybe the trick is to first capture the mode and upon closing the picker, restoring the captured mode?
Simon Hauser @.***> schrieb am Mi., 1. Dez. 2021, 20:22:
Okay thanks. I did manage to reproduce it. This happens for me if set fo+=a is set. Dont even need to set tw.
a Automatic formatting of paragraphs. Every time text is inserted or deleted the paragraph will be reformatted. See |auto-format|. When the 'c' flag is present this only happens for recognized comments.
So this matches what you said in your last finding
Only if I open the picker, start typing characters and then either press immediately or refine the match by further narrowing down with or , the buffer gets changed.
Because we insert text. I tried removing this option on telescope open and appending it on telescope close. But it didnt help. I also tried to remove it for only our buffers, also didnt work. But i also have to admit. I have no prior knowledge about formatoptions.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nvim-telescope/telescope.nvim/issues/1467#issuecomment-983980419, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABHE7SN7FW4ISTT6HZ5VVDUOZYXJANCNFSM5IL3QE3Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Any suggestions on how to fix this bug? I'm having this too