Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onEnterRules in language configuration seems to break editor #12

Open
timdmackey opened this issue May 6, 2021 · 1 comment
Open

onEnterRules in language configuration seems to break editor #12

timdmackey opened this issue May 6, 2021 · 1 comment

Comments

@timdmackey
Copy link

timdmackey commented May 6, 2021

When a language configuration file contains onEnterRules, the editor seems to choke on them any time the [Enter] key is pressed. I get an error each time says Uncaught Error: e.reg.test is not a function, which sounds like it's attempting to apply the rules but it's not recognizing them as a proper Regular Expression.

The only way I've found to fix this is to delete the onEnterRules. Are these rules explicitly unsupported, or is there something I can do to get them working? It looks like Monaco supports them by default, but perhaps they weren't implemented here when the textMate grammar support was added.

@timdmackey
Copy link
Author

timdmackey commented May 6, 2021

I figured out a bandaid solution to this, as I haven't tried to puzzle through a proper solution. The getProp() and setProp() functions in configuration.ts expect to receive objects, but onEnterRules is an array of objects. Since the objects don't have keys (but do have indexes), my solution was to just define each rule inside the REGEXP_PROPERTIES declaration a bunch of times. Messy, but it does the trick.

const REGEXP_PROPERTIES = [
  // indentation
  'indentationRules.decreaseIndentPattern',
  'indentationRules.increaseIndentPattern',
  'indentationRules.indentNextLinePattern',
  'indentationRules.unIndentedLinePattern',

  // code folding
  'folding.markers.start',
  'folding.markers.end',

  // language's "word definition"
  'wordPattern',

  // on enter actions
  'onEnterRules.0.beforeText',
  'onEnterRules.1.beforeText',
  'onEnterRules.2.beforeText',
  'onEnterRules.3.beforeText',
  'onEnterRules.4.beforeText',
  'onEnterRules.5.beforeText',
  'onEnterRules.6.beforeText',
  'onEnterRules.7.beforeText',
  'onEnterRules.8.beforeText',
  'onEnterRules.9.beforeText'
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant