Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[vim] Brace matching incorrectness #1031

Closed
siefkenj opened this Issue · 5 comments

3 participants

@siefkenj

when matching braces, say '(' and ')', vim will use the fact that it knows what parts of the code are quotes and comments, etc to properly match braces. vim.js currently doesn't do this and so matching on the first parent of ( ')' ) will match to the quoted close paren. Is there a way to figure out from codemirror what is comments and quotes and regexes, etc. to properly match braces?

@marijnh
Owner

It could do what lib/util/matchbrackets.js does -- use getTokenAt to get the style of the thing you're matching against, and only count brackets that use the same style.

@mightyguava
Owner

I like that idea. We could defer to matchbrackets.js when findMatchingBracket is available and use vim.js's if it's not. The issue is that matchbracket is only available in v3 and I'd like to keep improvements in v2 with vim.js. Is it only the "cursorActivity" event what makes it need to be a v3 util?

I wouldn't mind overwriting vim.js's implementation either (assuming we can get it into v2), matchbracket.js looks to be strictly better. Forcing people to pull in a 60 line file to enable bracket matching doesn't sound too bad.

@marijnh
Owner

As you noticed, matchbrackets.js is only in v3 because it requires being able to register cursoractivity handlers without stepping on other components that might be doing the same. It also requires defineOption, which is only in v3. It might be an okay compromise to have vim.js defer to matchbrackets on the v3 branch, and copy-paste in the relevant methods on the master branch.

@mightyguava
Owner

The brace matching issues mentioned should have been fixed by @lynschinzer's fix above. @siefkenj would you mind verifying and closing?

@siefkenj

Looks fixed to me :-).

@siefkenj siefkenj closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.