improvedft icon indicating copy to clipboard operation
improvedft copied to clipboard

t/T lands the cursor in an unexpected place when multi-character support is enabled

Open UrsaDK opened this issue 3 years ago • 2 comments

First of all, thanks a lot for the plugin! I have been using it for years but never had a chance to say thank you. It's simple, non-intrusive, and does exactly what you expect… most of the time! :)

The only exception from that rule appears to be if I use t or T when g:ft_improved_multichars is set to 1. In that case, running the following lends me on the second occurrence of g:

echo "abcdefgx abcefgy" > test.txt
nvim -c 'normal tabcdefgy' test.txt

However, at least to me, the expected behaviour would be to land on the second occurrence of b.

Additional info:

$ sw_vers                                             
ProductName:	macOS
ProductVersion:	12.6
BuildVersion:	21G115
$ nvim --version                                      
NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Monterey

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.8.0/share/nvim"

Run :checkhealth for more info

UrsaDK avatar Oct 15 '22 12:10 UrsaDK

normal tabcdefgy

Hm, what exactly are you trying to do?

I guess this should jump to the string starting with abcdefg and then y (yank)?

It's not clear to me.

Note: In general I have a feeling that the multichar feature was a mistake. I should probably remove that feature. It causes more pain and is not really useful.

chrisbra avatar Dec 20 '22 10:12 chrisbra

Hm, what exactly are you trying to do?

My apologies, I must have been very tiered when I wrote this report. Let me correct a few inconsistencies, get rid of the noise in the example, and explain the issue in a few more details:

  1. Create the test file: echo "az12 bz56 cz89" > test.txt
  2. Open the test file with neovim but without loading any plugins – nvim --noplugin test.txt. For simplicity sake, we'll use the middle word (bz56) to establish baseline behaviour:
    • Jump to the end of the first word ^e (this is only needed so that our next search targets the middle word), followed by tz – the cursor lends on b
    • Jump to the start of the last word $b (this is only needed so that our next search targets the middle word), followed by Tz – the cursor lends on 5
  3. Open the test file with neovim (nvim ./test.txt) and ensure that improvedf is enabled, and g:ft_improved_multichars is set to 1
    • Jump to column 1 (^) and search for the middle z with tz5 – the cursor lands on the middle z (col 7), not b as above.
    • Jump to the last column ($) and search for the same middle z with Tz5 – the cursor lands on 6, not 5 as above.

I hope this clarifies the issue a bit.

Note: In general I have a feeling that the multichar feature was a mistake. I should probably remove that feature. It causes more pain and is not really useful.

At the end of the day, it's your plugin and I'm sure we would all understand if you wanted to take it in a slightly different direction. But, from my personal point of view, it would be a real shame if you dropped support for multichar.

Out of all similar plugins I've used (sneak, easymotion, etc), I feel like yours really nails the multichar support: it's simple, it doesn't get in the way of other functionality, and it closely follows vim's built-in behaviour.

UrsaDK avatar Dec 25 '22 19:12 UrsaDK