telescope.nvim icon indicating copy to clipboard operation
telescope.nvim copied to clipboard

current_buffer_fuzzy_find changes buffer after selecting entry from picker

Open the42 opened this issue 4 years ago • 7 comments

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

the42 avatar Nov 19 '21 10:11 the42

Its not expected behavior but i also cant reproduce. Mind sharing a video :laughing:

I am also interested in the checkhealth error you mentioned.

Conni2461 avatar Nov 26 '21 11:11 Conni2461

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

the42 avatar Nov 29 '21 07:11 the42

I just discovered that the behavior is the same in Windows or Linux.

the42 avatar Nov 29 '21 07:11 the42

This is the minimum to replicate the error:

  1. Open nvim

  2. set :set fo=atnqw :set tw=70

  3. Type some random words, wait for the line to break automatically.

  4. Go to line 1, manually join 'J' with the automatically broken line 2

  5. run :Telescope current_buffer_fuzzy_find

  6. Type any string pattern which can be found on the line in the buffer

  7. hit <CR>

  8. See the line split again

the42 avatar Dec 01 '21 18:12 the42

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.

Conni2461 avatar Dec 01 '21 19:12 Conni2461

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.

the42 avatar Dec 01 '21 21:12 the42

Any suggestions on how to fix this bug? I'm having this too

guedesfelipe avatar Feb 09 '22 14:02 guedesfelipe