monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

get matching bracket position

Open ArunPatal opened this issue 7 years ago • 2 comments

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

ArunPatal avatar Mar 21 '19 19:03 ArunPatal

You can use https://blog.scottlogic.com/2015/01/20/typescript-compiler-api.html reference code

yln99517 avatar Apr 15 '19 11:04 yln99517

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;

alexdima avatar Dec 12 '19 08:12 alexdima