codemirror / codemirror5

In-browser code editor (version 5, legacy)
http://codemirror.net/5/
MIT License
26.7k stars 4.96k forks source link

[closebrackets] Support conditionally disabling close bracket behavior #6391

Open michaelquinn32 opened 3 years ago

michaelquinn32 commented 3 years ago

Hi team!

The R language has a system of doxygen headers (see https://github.com/r-lib/roxygen2) where the header is identified by this character combination #'. For this combination of characters, I would like autoclosing of quotes to be disabled. That way, I don't need to delete the automatically generated extra character.

Expected: I type #' and it stays like that. Otherwise, autoclosing quotes behaves the same. Actual: I type #' and autoclose produces #''

This could be an option for a specific language or a user-defined option. I wouldn't mind disabling that sequence for any language that I'm working in.

Thanks!

marijnh commented 3 years ago

I think this would work best as an extra setting (as per getOption in closebrackets.js) that provides a test function that, when it is available and returns false when called on the current editor, prevents the closing from happening. We could call it onlyIf or something. Would you be interested in submitting a pull request like that?