tcomment_vim icon indicating copy to clipboard operation
tcomment_vim copied to clipboard

Handling of canceled operator (selection) via textobj-user

Open blueyed opened this issue 8 years ago • 3 comments

I've noticed that when the if ("inner function") operator from textobj-user-python (via textobj-user) gets canceled (because there is no function on / around the cursor), tcomment's gcif will still comment some lines.

foo

becomes

#
# foo

Adding a echom to tcomment#Operator shows that lbeg is 189 and lend is 188 (which is normally the other way around).

It can also happen that begin and end are both 189 and then tcomment says "Comment mode is not supported for the current filetype"?!

I am not sure where the '[ and '] marks get set really, but the canceling goes through this code:

https://github.com/kana/vim-textobj-user/blob/a3054162c09bcf732624f43ddacbd85dad09713b/autoload/textobj/user.vim#L577 and https://github.com/kana/vim-textobj-user/blob/a3054162c09bcf732624f43ddacbd85dad09713b/autoload/textobj/user.vim#L651-L656

Is it possible to communicate a cancelation in this case?

/cc @kana

blueyed avatar May 30 '16 19:05 blueyed

I'm not sure what you mean by cancellation. if is supposed to visually select some text the operator works on. gcif should yield the same result as vifgc.

tcomment thinks you want to comment in inline mode which isn't supported for python. There currently is no map to force line-wise comments. You could simply use gcc though.

tomtom avatar Feb 09 '17 15:02 tomtom

I'm not sure what you mean by cancellation. if is supposed to visually select some text the operator works on.

Yes, but that might fail (in the case there is no function). That is the special case about this issue.

blueyed avatar Feb 09 '17 18:02 blueyed

Yes, but that might fail (in the case there is no function). That is the special case about this issue.

In HEAD, there is <Plug>TComment_gC that could be mapped to gC to enforce linewise commenting. Please let me know if this helps.

 nmap <silent> gC <Plug>TComment_gC

tomtom avatar Feb 09 '17 19:02 tomtom