Skip to content
This repository was archived by the owner on Nov 4, 2023. It is now read-only.

Allow bracket pairs to share open tokens or close tokens#310

Open
DragWx wants to merge 1 commit into
CoenraadS:developfrom
DragWx:develop
Open

Allow bracket pairs to share open tokens or close tokens#310
DragWx wants to merge 1 commit into
CoenraadS:developfrom
DragWx:develop

Conversation

@DragWx

@DragWx DragWx commented Jul 10, 2020

Copy link
Copy Markdown

This addresses issue #301. Initial testing allows the Verilog case and endcase tokens to match correctly, and doesn't seem to break any other files I opened.

This modification does three things:

  1. Adds pairsWith to Token and everything that instantiates tokens.
  2. When loading the textmate languages, braces are still only added once to the map, but pairsWith is now used to keep track of which open braces have been paired with which closing braces, to allow one-to-many associations.
  3. In AddCloseBracket, the open brace checks its pairsWith list to determine if the close bracket should be a match, instead of checking for like keys.

@skrobchik

Copy link
Copy Markdown

#170 Could this be related?

@DragWx

DragWx commented Apr 10, 2021

Copy link
Copy Markdown
Author

Without knowing the exact extension you're using for LaTeX support, I just searched the marketplace for one and found LaTeX Workshop. Inside LaTeX-Workshop/syntax/syntax.json are the following bracket definitions:

	"brackets": [
		["{", "}"],
		["[", "]"],
		["(", ")"],
		["\\left(", "\\right)"],
		["\\left(", "\\right."],
		["\\left.", "\\right)"],
		["\\left[", "\\right]"],
		["\\left[", "\\right."],
		["\\left.", "\\right]"],
		["\\left\\{", "\\right\\}"],
		["\\left\\{", "\\right."],
		["\\left.", "\\right\\}"],
		["\\left<", "\\right>"]
	],

Sure enough, there's some sharing going on between these tokens, so issue #170 is very likely to be related.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants