Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: failed to uncomment when highlight link is nested #176

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

uplus
Copy link
Contributor

@uplus uplus commented Jan 18, 2022

Problem

When highlight link is nested, caw.vim fails to uncomment.

Cause

In the current implementation, s:comment_detectable.has_syntax uses synIDtrans to get the terminal syntax name.
If the terminal syntax name does not contain Comment, s:comment_detectable.has_syntax will return 0.

if synIDattr(synIDtrans(id), 'name') =~# a:synpat

For exacmple.

hi! link vimLineComment Comment
hi! link Comment hogeColor
hi! hogeColor ctermfg=8

let id = hlID('vimLineComment')
echo synIDattr(synIDtrans(id), 'name') " 'hogeColor'

For example, it will succeed if the highlight settings are as follows.

hi! link vimLineComment Comment
hi! Comment ctermfg=8

let id = hlID('vimLineComment')
echo synIDattr(synIDtrans(id), 'name') " 'Comment'

Solution

Use both synIDattr(id, 'name') and synIDattr(synIDtrans(id), 'name').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant