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

It's not possible to detect concealment from matchadd #9283

Open
resolritter opened this issue Dec 5, 2021 · 0 comments
Open

It's not possible to detect concealment from matchadd #9283

resolritter opened this issue Dec 5, 2021 · 0 comments

Comments

@resolritter
Copy link

Is your feature request about something that is currently impossible or hard to do? Please describe the problem.

If a [row,col] position is concealed through matchadd("Conceal", ...) then there's no way to detect its concealment, unlike positions concealed through syn match [pattern] which can be detected through synconcealed.

Demonstration

set conceallevel=2 concealcursor=nvic
call feedkeys("i \<esc>", "n")
call matchadd("Conceal", '^\s*', 10, -1, { "conceal": "" })
fun! OnVimEnter(...)
  echo synconcealed(line('.'), col('.'))
endfun
autocmd VimEnter * call timer_start(0, function("OnVimEnter"))

Using the above script, [0, '', 0] will be printed from synconcealed although the character is, in fact, concealed.

The same approach, but replacing matchadd("Conceal",...) for syn match [pattern]:

set conceallevel=2 concealcursor=nvic
call feedkeys("i \<esc>", "n")
syntax match Concealment /^\s*/ conceal
fun! OnVimEnter(...)
  echo synconcealed(line('.'), col('.'))
endfun
autocmd VimEnter * call timer_start(0, function("OnVimEnter"))

Using the above script, [1, '', 1] will be printed from synconcealed and that can be used to detect the concealment.

Describe the solution you'd like

Extend synconcealed to also work for characters concealed through matchadd or create a new matchconcealed API for detecting them.

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

No branches or pull requests

1 participant