Check if cursor inside <?php
I am trying to check whether the cursor is encapsulated in <?php ?>.
I need to check this to determine whther a string for a write actions needs to contain a php opening tag or not.
I tried to check it via the language of the psi element at the current caret, but mostly the psi element is null.
Is there any other method to check this?
请先登录再写评论。
My code is:
If the caret is at whitespace language is null.
Will it always be null at whitespace?
I got a solution it may not be the best, but it works: