unblevable / quick-scope

Lightning fast left-right movement in Vim
MIT License
1.43k stars 54 forks source link

Error when using `highlight_on_keys` #80

Closed mohad12211 closed 2 years ago

mohad12211 commented 2 years ago

If I use highlight on keys, like this: vim.cmd "let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']" I get an error, for one time, then the error goes away and everything is alright

https://user-images.githubusercontent.com/51754973/146658959-e655b9e3-5273-4d3f-9150-585ac95ae1ca.mp4

nvim version: 0.6.0 luajit 2.0.5

Cnly commented 2 years ago

I'm getting two similar errors:

Error detected while processing function <SNR>206_AutoUpdate[98]..<SNR>206_SetStatusLine[10]..<SNR>206_goto_win:
line   20:
E523: Not allowed here

where <SNR>206 is tagbar/autoload/tagbar.vim, as well as

Error detected while processing function quick_scope#Aim:
line   26:
request error nvim_call_function - Vim(call):E5555: API call: E523: Not allowed here use :CocOpenLog for details

which seems to be related to coc.nvim.

The one with tagbar can be fairly consistently reproduced when tagbar is open.

Cnly commented 2 years ago

I saw that E523: Not allowed here seems to appear in every error so after reading https://stackoverflow.com/questions/59440719/vime523-not-allowed-here I tried to make a little patch for this.

@mohad12211 could you help confirm whether this also fixes your case? The patched version is available in https://github.com/Cnly/quick-scope.

mohad12211 commented 2 years ago

@Cnly I now have a new error with your version: image

same process, it's only the first time I press f or t for one time, then the error goes away and I can use everything with no problems, until I restart.

Cnly commented 2 years ago

@mohad12211 Do you have Ctrl-c mapped to anything in normal mode? If so, what is it?

mohad12211 commented 2 years ago

actually yes, I didn't know that, I'm new to nvim and this is not my configs xD it's mapped to vimp.nmap('<C-c>', ':bp|bd #<CR>') which clears the current buffer apparently, the error is gone when I removed it, why is that tho? quick-scope doesn't use ctrl-c for anything right?

Cnly commented 2 years ago

When you hit one of the keys in highlight_on_keys, quick-scope temporarily remaps ctrl-c so you can use it to cancel the action. Your error happens while your previous mapping is being restored, when the | character (command separator) didn't get escaped and the restoration effectively becomes the execution of two commands nmap <c-c> :bp and bd #<CR>.

I've pushed a new commit. Could you try that?

mohad12211 commented 2 years ago

@Cnly Nice! that works perfectly. will you make a PR to this repo? Edit: oh you already made one, @unblevable Please consider merging it

bradford-smith94 commented 2 years ago

I've been reading along as this has progressed. Thanks for your work @Cnly, I'll try to make time to review and merge tomorrow.

Cnly commented 2 years ago

@mohad12211 Thanks for testing and @bradford-smith94 thanks for following along! I realised I don't have to change the body of quick_scope#Aim() so I've simplified the code further. It's now a change < 10 LoC and shouldn't be a burden to review.