ggandor / lightspeed.nvim

deprecated in favor of leap.nvim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cursor stuck at command line when jumping to unique characters

opened this issue · comments

I have this problem with what is called "jump on partial input" in the README.

Say I press s + a unique (bold) character. What happens after is that the cursor is in the command line (below statusline) and not on the unique character. I need to press esc as well for it to be moved from the command line to this character.

I have done zero configuration of lightspeed and the nvim version is 0.5.1.

Hi! This is not a bug, but the "safety timespan" feature in action. The cursor is indeed down on the command line, and technically we're still executing, waiting for input, but if you press any key, it will simply be fed forward and interpreted normally, except if it is the follow-up character (i.e., Y if you're jumping to XY), and the timeout is not exceeded yet. This can be set via opts.jump_to_unique_char_safety_timeout, 400ms by default.

The reason for this feature is that if the highlighting of the unique characters are turned off (but sometimes even in that case) you would often enter XY quickly, in one go, without realizing that X is unique, and an automatic jump will happen. If we would simply exit after X unconditionally, then Y would be interpreted as a Normal-mode command, with potentially destructive consequences :) This is briefly mentioned in the README in the relevant section ("to further mitigate accidents..."). I hope everything is clear now!

Thanks.

In your example gif of this your cursor is in both places after pressing the unique character (or maybe the "cursor" on the unique character is just a highlight and the actual cursor is on the command line). In my case though when I press the unique character there is no highlight on the unique character or anywhere in the text, only a cursor in the command line. Therefore I have no idea where I am at or what is happening. I tried disabling highlights for CursorLine and settings regarding that, but it's the same still.

Also I don't know what the timeout does since I notice no difference in any behavior after waiting. The second key is interpreted normally (e.g. i is insert) regardless of waiting.

Oh, okay... so the cursor does move (if cursorline is on, you see the line changing), but there's some problem with the (temporary) cursor highlight? When you press s, do you see the cursor highlighted, or it disappears right away, i.e. the temporary highlight does not work at all? When you check :hi Cursor, are there properties defined for the group? If not, then the cursor will be invisible, because we're using the Cursor group by default, if LightspeedCursor is not configured (I mentioned this problem in the README here).

Also I don't know what the timeout does since I notice no difference in any behavior after waiting. The second key is interpreted normally (e.g. i is insert) regardless of waiting.

If you're targeting an Xi, and X is unique, and you press i very quickly after X (< 400ms), then nothing should happen. After this, i starts Insert mode, like normally.

The issue was the Cursor highlight group. By default only guifg and guibg was set. The temporary highlight doesn't work in the terminal by default.

Solved by adding vim.cmd[[highlight Cursor ctermfg=NONE ctermbg=NONE cterm=reverse]] to init file.