monaco-editor
monaco-editor copied to clipboard
get matching bracket position
Let's say if i have position of open bracket, Is there a way to get the position of the matching (close) bracket on editor?
Thanks
You can use https://blog.scottlogic.com/2015/01/20/typescript-compiler-api.html reference code
There is an internal method on the model, i.e. editor.getModel():
/**
* Given a `position`, if the position is on top or near a bracket,
* find the matching bracket of that bracket and return the ranges of both brackets.
* @param position The position at which to look for a bracket.
* @internal
*/
matchBracket(position: IPosition): [Range, Range] | null;