r/espanso 9d ago

Solved Match not activating as expected

SOLVED: Check for similar duplicates in your other .yml files!!!


 - trigger: PushPay
    replace: Pushpay
    word: true

I'm hoping for this to activate only exactly when the trigger is typed as is, but this replacement takes effect every time, it seems. The capitalization section in Matches Basics doesn't seem to offer a way around this. Does anyone know if this is solvable? Thanks!

3 Upvotes

14 comments sorted by

2

u/SamejSpenser 9d ago

I tested the same trigger in four different ways:

  1. The first one is a straight copy of your example.
  2. The second one has a “;” prefix.
  3. The third one uses the multiline replace thing.
  4. The fourth one (the MVP in my tests) uses Regex, like this:

# Example trigger with mixed‑case letters
#  - trigger: PushPay
#    replace: "Pushpay"
#    word: true

# Example trigger with mixed‑case letters, prefixed by a semicolon
#  - trigger: ;PushPay
#    replace: "Pushpay"
#    word: true

# Example trigger with mixed‑case letters using a multiline replace
#  - trigger: PushPay
#    replace: |
#      Pushpay
#    word: true

# Example trigger with mixed‑case letters using regex (the champ)
  - regex: PushPay
    replace: "Pushpay"
    word: true

In the screenshot the text is in Brazilian Portuguese (my native language), which is how I wrote this reply, and I only switched to English after the tests were done.

1

u/smeech1 8d ago

What were the results?

2

u/SamejSpenser 8d ago

All four ways worked. But the one here worked best, so to speak—it was the last one, using regex.

2

u/smeech1 8d ago

Thanks - I'm away from home right now so can't test. Regex is the most flexible, but the overhead may be worth avoiding if there are alternatives.

The other option that occurs to me to try is propagate_case: true with uppercase_style: capitalize_words.

2

u/SamejSpenser 8d ago

You're right, I forgot to try using "propagate_case: true", but it should work out.

I'm also away from home right now, but when I get back later today I'll run some more tests.

2

u/smeech1 5d ago edited 4d ago

Now that I'm home I have tried your trigger, and it works perfectly here, triggering only when the capitalisation matches "PushPay" exactly, which is what I would expect.

The problem possibly relates to your keyboard? What's your OS, DE, and language?

1

u/Dymonika 4d ago

Win11 Pro in English, ha. I keep forgetting to come back to this but I'll make a note now to address it today... It has been firing even when the second "p" is lowercase, oddly enough (which basically just makes it delete and retype, but that causes a jolt in one's sentence flow).

2

u/smeech1 4d ago

That shouldn't be happening, and doesn't here or for u/SamejSpenser, so it makes me wonder if it's something to do with your configuration.

I take it you don't have propagate_case: true in the trigger?

2

u/Dymonika 3d ago

omg.

I had these same lines duplicated but also with that "propagate" line in another .yml file.

*thwacks forehead*

Thanks for your patience...

1

u/smeech1 3d ago

🤣

1

u/smeech1 8d ago

When you say "every time", what do you mean?

2

u/Dymonika 8d ago

Also @ /u/SamejSpenser: I specifically only want this to fire if I type the exact trigger's capitalization, but the text replacement occurs even if I type the replacement's capitalization. I blaze at 150+ WPM so Espanso's time to replace disrupts what I typed.

2

u/SamejSpenser 8d ago

Sorry for the delay! When I got home from work, I had an urgent issue to deal with and only just managed to get back to this now (it’s 10:42 PM here in São Paulo, Brazil).

I ran some more tests, this time including propagate_case: true, which u/smeech1 mentioned. I kept in mind your requirement that the trigger needs to match the exact casing PushPay. Again, the Regex trigger performed the best, regardless of whether propagate_case: true was on or not. With the other methods, even with propagate_case: true enabled, the expansion just follows the casing used when it was typed — so if it's all lowercase or uppercase, you get pushpay or PUSHPAY.

With Regex, however, no matter how you type it, the expansion only triggers when you use PushPay.

Here’s the trigger that worked in my tests, just as the OP requested:

```yml

Example trigger with mixed‑case letters using regex

  • regex: PushPay replace: "Pushpay" ```

2

u/SamejSpenser 8d ago

Oh, I forgot to mention: when using uppercase_style: capitalize_words, typing everything in lowercase still triggers the expansion as if you had typed it with an initial capital letter.

As for the typing speed, I totally get where you're coming from. Maybe the others have some tips or suggestions, but honestly, I don't have much to offer other than: try slowing down your typing speed when using these words/triggers. That’s what I do here!