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

Add option to lower or disable the Windows keyboard layout cache invalidation interval #745

Closed
grenudi opened this issue Aug 30, 2021 · 7 comments
Labels
windows Related to the Windows operating system

Comments

@grenudi
Copy link

grenudi commented Aug 30, 2021

Tested on several machines - same behaviour/
When I switch to any input field triggers doesn't work right away, I have to type some random characters first and delete them, only then trigger words expands normally.

Any advice how to diagnose/fix this ?
I use your extension in my work, with several colleagues and it's very important.
Thanks a lot for your work !

@federico-terzi
Copy link
Collaborator

Hey @grenudi,

Thanks for reporting this issue! Could you post an example of these problematic triggers? I'm particularly curious to see if you are using the word: true option

Cheers :)

@federico-terzi federico-terzi added bug Something isn't working windows Related to the Windows operating system labels Aug 30, 2021
@grenudi
Copy link
Author

grenudi commented Sep 3, 2021

Hey @grenudi,

Thanks for reporting this issue! Could you post an example of these problematic triggers? I'm particularly curious to see if you are using the word: true option

Cheers :)

For some reason it works like a charm when I try to record it...

No, I do not use word: true option in any trigger, all my triggers start and end with same symbols, for example -test- , .test. , also option backend: Clipboard have no effect either.

This doesn't depend on usage of type: "clipboard" option as well, though it is used in the demo bellow, nor does it bound to html, nor markdown, nor replace options.

Video demo of -зак- trigger

UJUkjLUyNB.mp4
  - triggers: ["-закз-"]
    html: |+
      <p>
      <strong>Запрос закрыт согласно комментарию заявителя:</strong>
      <blockquote>{{cb}}</blockquote>
      {{clo}}
      </p>
    vars:
      - name: "cb"
        type: "clipboard"
      - name: clo
        type: match
        params:
          trigger: "-зак-"

All contents of file cloacu--close-according-to-users-reply.yml

parent: default

# Mnemonic   : XXX
# Description: XXX
# Data Source: XXX
# TODO: XXX

matches:
# ENGLISH
  # - triggers: ["  "]
  #   replace: |+

  # - triggers: [".."]
  #   markdown: |+

  - triggers: ["-cloacu-"]
    html: |+
      <p>
      <strong>[Closed according to requesters reply]</strong>
      <blockquote>{{cb}}</blockquote>
      {{zak}}
      </p>
    vars:
      - name: "cb"
        type: "clipboard"
      - name: zak
        type: match
        params:
          trigger: "-clo-"

# RUSSIAN
  # - triggers: ["  "]
  #   replace: |+

  # - triggers: [".."]
  #   markdown: |+

  - triggers: ["-закз-"]
    html: |+
      <p>
      <strong>Запрос закрыт согласно комментарию заявителя:</strong>
      <blockquote>{{cb}}</blockquote>
      {{clo}}
      </p>
    vars:
      - name: "cb"
        type: "clipboard"
      - name: clo
        type: match
        params:
          trigger: "-зак-"

# You can refer to the official documentation:
# https://espanso.org/docs/

FILE default.yml

# espanso configuration file

#### OPTIONS #### 
# https://espanso.org/docs/configuration/#options

backend: Clipboard

matches:
  # Testing
  - trigger: "  test"
    replace: "THIS IS TEST SO STFU test"

#YAML CHEATSHEET:
#                       >     |            "     '     >-     >+     |-     |+
# -------------------------|------|-----|-----|-----|------|------|------|------  
# Trailing spaces   | Kept | Kept |     |     |     | Kept | Kept | Kept | Kept
# Single newline => | _    | \n   | _   | _   | _   | _    |  _   | \n   | \n
# Double newline => | \n   | \n\n | \n  | \n  | \n  | \n   |  \n  | \n\n | \n\n
# Final newline  => | \n   | \n   |     |     |     |      |  \n  |      | \n
# Final dbl nl's => |      |      |     |     |     |      | Kept |      | Kept  
# In-line newlines  | No   | No   | No  | \n  | No  | No   | No   | No   | No
# Spaceless newlines| No   | No   | No  | \   | No  | No   | No   | No   | No 
# Single quote      | '    | '    | '   | '   | ''  | '    | '    | '    | '
# Double quote      | "    | "    | "   | \"  | "   | "    | "    | "    | "
# Backslash         | \    | \    | \   | \\  | \   | \    | \    | \    | \
# " #", ": "        | Ok   | Ok   | No  | Ok  | Ok  | Ok   | Ok   | Ok   | Ok
# Can start on same | No   | No   | Yes | Yes | Yes | No   | No   | No   | No
# line as key       |

tmp:
  filesharing: |+
    - Для данных задач вы можете использовать https://web.microsoftstream.com/ , при записи вебинара в тимс он автоматически сохраняется в MS Stream
    - В ручную можно делиться любыми файлами через https://nxcloud.softline.com/ (по умолчанию срок хранения 14 дней, продлевается по запросу или "перезаливом" файла).
    - Корпоративный OneDrive

    [
    Инструкция по работе с файлами: https://wiki.softline.com/pages/viewpage.action?pageId=693207842
    Инструкция по работе с OneDrive: https://wiki.softline.com/pages/viewpage.action?pageId=693207842
    ]

@grenudi
Copy link
Author

grenudi commented Sep 3, 2021

I think I've found the reason behind it.. This is due to keyboard layout switch, and at work I change layout many times per minute.
Here is a demo:

8Smp1U7VFn.mp4

@federico-terzi
Copy link
Collaborator

federico-terzi commented Sep 3, 2021

Hey @grenudi,

Thank you so much for the detailed report! Indeed, there is a keyboard layout "cache" on Windows (see: https://github.com/federico-terzi/espanso/blob/master/native/libwinbridge/bridge.cpp#L47 and https://github.com/federico-terzi/espanso/blob/master/native/libwinbridge/bridge.cpp#L238) currently set to 2 seconds. This causes espanso to "miss" some characters if the layout change occurs soon before.

I'd say we might want to introduce a configurable option to either lower the cache invalidation time or disable it entirely. I'll convert this issue to a feature request!

Cheers :)

@federico-terzi federico-terzi changed the title Windows 10, have to type trigger twice Add option to lower or disable the Windows keyboard layout cache invalidation interval Sep 3, 2021
@federico-terzi federico-terzi added Feature and removed bug Something isn't working labels Sep 3, 2021
@grenudi
Copy link
Author

grenudi commented Sep 6, 2021

@federico-terzi can you please advice how can I deal with it at the moment ?

@federico-terzi
Copy link
Collaborator

federico-terzi commented Sep 6, 2021

@grenudi The easiest way would be to wait for #594 to be released (hopefully by the end of September). At that point, we should be able to ship this feature as well.
Otherwise, you might try compiling espanso yourself after changing that value, though it's not trivial on Windows currently (the upcoming version will be much easier).

I'm really sorry I can't offer you anything sooner, but our limited resources are all dedicated to shipping the upcoming release :) After that, we'll move to "bug fixing" mode, including this one

Cheers :)

@federico-terzi
Copy link
Collaborator

Hey @grenudi,

The next version (v2.0.4-alpha) will include a fix for this problem, thank you for the help! :)

You will need to specify the following in your $CONFIG/config/default.yml file:

win32_keyboard_layout_cache_interval: 300

Feel free to lower that value if needed, but keep in mind that the higher it is, the more efficient espanso is (by default it's 2000)

Cheers :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
windows Related to the Windows operating system
Projects
None yet
Development

No branches or pull requests

2 participants