tcomment_vim
tcomment_vim copied to clipboard
Handling of canceled operator (selection) via textobj-user
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
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.
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.
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