How get token from updateListener.of

Hello ) How are you ?
Maybe you know, how to get a token (lezer token) from updateListener.of as we can do it in context.tokenBefore([])

EditorView.updateListener.of((mirror: ViewUpdate) => return just text .

  const viewState = mirror.state;
  const range = viewState.selection.ranges[0];
  const textPos = viewState.wordAt(range.from);

  if (textPos) {
    const text = viewState.sliceDoc(textPos.from,;

I am using not only letters but also characters.
How or Can i get the full data of the text from the current position as a token block.

For example - my token is #word.word!C1 - and when a user is clicking on this text i want to check - what is the token, and the text inside it. But i can get only part of it - word

And i hope is some way - not only -
const prevPos = viewState.wordAt(textPos.from - 1);

or some idea how to get character before and after the selected text.

syntaxTree(state).resolve(pos) might help here (though it doesn’t do exactly the same thing as tokenBefore, but you can see how that’s implemented and do something similar if needed).

1 Like

thank you )
holy codemirror - it can helps )
and it do )

const co = syntaxTree(viewState).resolve(range.from);

  • it gives me all token that i want - so similar with tokenBefore
    because i have text and position ( co.from, )
    and more - show me infromation about current token )