AndrewRadev / sideways.vim

A Vim plugin to move function arguments (and other delimited-by-something items) left and right.
http://www.vim.org/scripts/script.php?script_id=4171
MIT License
481 stars 9 forks source link

Bug when &selection=exclusive #11

Closed gelguy closed 9 years ago

gelguy commented 9 years ago

The ReplaceMotion at https://github.com/AndrewRadev/sideways.vim/blob/master/autoload/sideways/util.vim#L92 does not take into account when &selection is exclusive.

Steps to reproduce: just set selection=exclusive, and try SidewaysRight.

This is because gov is assuming the visual selection is inclusive. Selection should be set to inclusive before doing ReplaceMotion:

  let old_selection = &selection
  let &selection = 'inclusive'
  call sideways#util#ReplaceMotion(start_byte.'gov'.end_byte.'go', a:text)
  let &selection = old_selection

I'm not sure about the exact architecture of the plugin, and it should be possible to refactor the selection setting so it is only called once per :SidewaysRight/Left call.

AndrewRadev commented 9 years ago

Thanks, I've made some changes to the plugin that should account for selection=exclusive. I didn't try to place the selection setting to once per call, since it seems easy to miss a place. The plugin does a lot of saving and restoring of settings and there's really no noticeable performance hit from it.

Could you try the patch and see if it fixes your issue?

gelguy commented 9 years ago

This works as expected now. Thank you!