Skip to content

feat: Add max_regex_buffer_size config option - #2504

Merged
AucaCoyan merged 4 commits into
espanso:devfrom
aldair-meneses:add-max-regex-buffer-size-config-option
Oct 10, 2025
Merged

AucaCoyan merged 4 commits into
espanso:devfrom
aldair-meneses:add-max-regex-buffer-size-config-option

Conversation

@aldair-meneses

Copy link
Copy Markdown
Contributor

This PR introduces a new configuration option, max_regex_buffer_size, allowing users to control the maximum number of characters held in memory for regex trigger matching and solve the issue #1766 .

Context

Previously, the buffer size for regex matching was hardcoded to 30 characters. This posed a limitation for users wanting to create triggers longer than this size.
This change makes the regex buffer size configurable in the configuration, providing a better balance between capability and resource consumption, tailored to each user's needs.


Changes Made

  • New Configuration Option: Added max_regex_buffer_size to the configuration files, with a default value.
  • Config Trait: Updated the Config trait and its implementations to include the max_regex_buffer_size() method.
  • Engine Integration: The regex matcher now uses the value from the configuration instead of a hardcoded one.
  • Documentation: Added comments in both the source code and the default configuration file to explain the new option.

How to Test

  1. Open your default.yml configuration file.

  2. Set a small buffer size:

    max_regex_buffer_size: 10
  3. Create a match with a regex trigger longer than 10 characters:

    matches:
      - regex: ":thisislongerthan10"
        replace: "This should not work."
  4. Save the file and let espanso restart.

  5. Try to type :thisislongerthan10. The replacement should not occur.

  6. Now, increase the buffer size in default.yml:

    max_regex_buffer_size: 20
  7. Save and let espanso restart.

  8. Try to type :thisislongerthan10 again. The replacement should now work correctly.

@aldair-meneses
aldair-meneses force-pushed the add-max-regex-buffer-size-config-option branch from ca64bf9 to 0e9c78b Compare October 5, 2025 00:42
@AucaCoyan

Copy link
Copy Markdown
Collaborator

I tested it and it works perfectly!
Thank you so much for the effort, I think it's a contribution of really really good quality ❤️.
It's pending to add max_regex_buffer_size into schemas/config.schema.json only. I'll add it and merge

@AucaCoyan
AucaCoyan merged commit 514e18b into espanso:dev Oct 10, 2025
@smeech smeech mentioned this pull request Oct 10, 2025
53 of 56 tasks
sboldt1978 pushed a commit to sboldt1978/espanso that referenced this pull request Feb 11, 2026
* feat: Add max_regex_buffer_size config option

* formatting

* add key to the config.schema.json

* add settings for biomejs as formatter

---------
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

Successfully merging this pull request may close these issues.

2 participants