terryma / vim-expand-region

Vim plugin that allows you to visually select increasingly larger regions of text using the same key combination.
MIT License
1.1k stars 46 forks source link

First + sometimes shrinks selection #9

Open staticshock opened 9 years ago

staticshock commented 9 years ago

I saw a report of something similar (#3) but I'll open this separately anyway, since the other one is closed.

Here are some issues I'm seeing, using this code as an example:

call winrestview(s:candidates[s:cur_index].prev_winview)
  1. If the cursor is on the first character of winrestview, viw+ does not grow the selection beyond the initial word. If, however, the cursor is after the first character, viw+ seems to grow the selection. I can only reproduce this ~90% of the time, so it seems that there's some sort of a race going on.
  2. If I manually select winrestview(, hitting + actually shrinks the selection.
AdamWagner commented 4 years ago

I had the same issue. Disabling CamelCaseMotion (per https://github.com/terryma/vim-expand-region/issues/3) resolved this issue for me – expand selection now always expands selection. If you happen to have CamelCaseMotion installed, try disabling it.

golmman commented 3 years ago

It seems like 'iW/iw' and e.g. 'i]' are conflicting rules in phrases like [ [a: 1] ], so when the cursor is on a you could expand like [a: (encased by spaces, i.e. word) or like a: 1 (encased by []).

Removing the iW/iw rules in g:expand_region_text_objects helped for me. E.g.

let g:expand_region_text_objects = {
      \ 'i"'  :0,
      \ 'i''' :0,
      \ 'i]'  :1,
      \ 'ib'  :1,
      \ 'iB'  :1,
      \ 'il'  :0,
      \ 'ip'  :0,
      \ 'ie'  :0,
      \ }