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

Obsidian Hangs when a new regular expression is added #28

Open
mattcoleanderson opened this issue Dec 21, 2023 · 0 comments
Open

Obsidian Hangs when a new regular expression is added #28

mattcoleanderson opened this issue Dec 21, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@mattcoleanderson
Copy link
Owner

Problem

When adding a custom regex pattern int the plugins settings, Obsidian freezes with the following error logged to console:

Uncaught SyntaxError: Invalid regular expression: /(/dgm: Unterminated group (at plugin:dynamic-text-concealer:316:31)
    at new RegExp (<anonymous>)
    at eval (plugin:dynamic-text-concealer:316:31)
    at Array.forEach (<anonymous>)
    at ConcealPlugin.addEditorExtension (plugin:dynamic-text-concealer:310:34)
    at ConcealPlugin.updateEditorExtension (plugin:dynamic-text-concealer:322:14)
    at eval (plugin:dynamic-text-concealer:39:33)
    at t.onChanged (app.js:1:1320966)

Cause

When writing a new regex pattern in settings, the pattern is instantiated to a RegExp object prematurely.

Solution

The following changes need to be made:

  • A try-catch block around the RegExp instantiation
  • A save button in settings for the user to signify the regexp is ready for use
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant