Double closing brace from PairedBraceMatcher

I have a plugin for a custom language that has constructs like the following:

workflow foo {

   # content here

}

I implemented a PairedBraceMatcher (WdlBraceMatcher) for the language but I'm seeing odd behavior specifically for braces: when I type an opening `{` I get a closing `}` automatically, which is great! Unfortunately when I then press `Enter`, I get a second closing brace inserted, which breaks the code structure. Eg:

workflow foo {

  # cursor ends up here.

}

}

I found the option to turn off `Insert pair '}'` in Preferences but this hasn't been needed in any other language and seems like a strange default behavior (eg I typically write in Scala and haven't seen this double-closing before, despite the same option being on for me the whole time).

Is there any way I can restructure the PairedBraceMatcher or override smart keys in the plugin to prevent this from happening by default? Thanks!

0
3 comments

Update: I unset the 'structural' boolean in the BracedPairs returned by my getPairs method and this problem seems to have resolved.

I'm not 100% sure what 'structural' means but for now having it turned off for all pair-types seems to achieve everything I want!

0

It could have been related to the fact that WdlTypes.RBRACE token is a member of two different brace pairs, returned by your language's brace matcher. I doubt that platform code can handle this case correctly.

0

Thanks, Dmitry!

Since turning off structural for all brace types it seems to be working as I'd expect (tbh I never really understood what that was!)

I'll definitely bear that in mind and maybe change the token generator if I ever need to reenable "structural", thanks!!

0

Please sign in to leave a comment.