folke / flash.nvim

Navigate your code with search labels, enhanced character motions and Treesitter integration
Apache License 2.0
2.57k stars 34 forks source link

feature: support multibyte characters on offsetting labels and jumps #121

Closed atusy closed 1 year ago

atusy commented 1 year ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

Currently, colwise offset of labels and jumps are byte-wise.

https://github.com/folke/flash.nvim/blob/edb82f763ac2b63006154e9da8b6629b570de551/lua/flash/highlight.lua#L117

https://github.com/folke/flash.nvim/blob/5c9505a19edcbb236d367282584ed5f02ccd4fb4/lua/flash/jump.lua#L193

This results in the following examples to label on the same character, , although they have different after values {0, 1}, {0, 2}, and {0, 3}.

require("flash").jump({pattern = "あ", search = { wrap = false }, label = {after = {0, 1}, before = false}})
require("flash").jump({pattern = "あ", search = { wrap = false }, label = {after = {0, 2}, before = false}})
require("flash").jump({pattern = "あ", search = { wrap = false }, label = {after = {0, 3}, before = false}})

image

The above screenshot comes from a buffer below.

aaaあいx
aaaあいx

Describe the solution you'd like

I think offset should work char-wise not byte-wise.

Describe alternatives you've considered

none

Additional context

No response