Skip to content

Reduce accidental matches with max length setting #65

@ufukty

Description

@ufukty

Context

  • While a user is editing, a rule can unexpectedly match across section boundaries, starting inside an incomplete section and extending until it finds the closing sequence of the next one.
  • Dim already has one measure against accidental matches, which is brace balance checking. It's only effective for patterns that match sequences inside a scope and not across scopes.
  • Rewrites the readme and changelog #57 added a mention of the intent to prevent accidental matches1.

Problem

Rare accidental matches harm user experience.

Suggestion

  • Prevent accidental matches by enforcing a limit on the maximum characters per match.
  • Allow users to set per-rule limits and a default.
  • Ignore matches that exceed the effective rule limit.
  • The user configuration may look like this:
{
  "dim.rules": [
    { "pattern": "...", "max": 10 },
    { "pattern": "..." } // uses the default
  ],
  "dim.max": 100 // default
}

Considerations

Optional features:

  • LoC limit.
  • Language default for max.

Footnotes

  1. "Dim ... to prevent eye irritation and performance problems that would arise when incomplete sections of code cause a rule to match into the next section's ending. (Experimental)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions