espanso / espanso

Cross-platform Text Expander written in Rust
https://espanso.org
GNU General Public License v3.0
10.14k stars 280 forks source link

Different behavior in Wezterm & Kitty Terminal #1491

Open bashfulrobot opened 1 year ago

bashfulrobot commented 1 year ago

Describe the bug

To Reproduce Steps to reproduce the behavior:

example 1

  1. define the following:
    - trigger: ":test"
    replace: 'clear && MYVAR="hi there" && echo "hello one" && echo "hello two" && echo $MYVAR'
  2. open kitty and run the :test trigger
  3. the results are:
    clear 77 myvar='hi there' 77 echo 'hello one' 77 echo 'hello two' 77 echo 4myvar

example 2

  1. define the following:
    - trigger: ":t2"
    replace: 'clear && echo "Getting Files" && echo && MYPATH="/home/dustin/docker/files" && MYDEST="/home/dustin/docker/process" && cd $MYDEST && rsync --progress -avze ssh system:/mnt/path ./process-m && echo && echo "Renaming Files" && echo && docker run --rm -it -v $MYPATH/process-m:/process-m -v $MYDEST:/media -v data:/data repo/myimage -r -rename /process-m --log-file $MYDEST/logs/rename.log -non-strict && echo && echo "Setting Permissions" && echo && sudo chown -R dustin:dustin $MYDEST && MYVAR="/home/dustin/docker/files" && echo "Deleting Files" && echo && rm -rf $MYPATH/process-m/*'
  2. open kitty and run the :t2 trigger
  3. the results are:
    v

Expected behavior

Logs If possible, run espanso log in a terminal after the bug has occurred, then post the output here so that we can better diagnose the problem

❯  espanso log    
11:33:45 [daemon(36341)] [INFO] reading configs from: "/home/dustin/.config/espanso"
11:33:45 [daemon(36341)] [INFO] reading packages from: "/home/dustin/.config/espanso/match/packages"
11:33:45 [daemon(36341)] [INFO] using runtime dir: "/home/dustin/.cache/espanso"
11:33:45 [daemon(36341)] [INFO] system info: Pop!_OS v22.04 - kernel: 6.0.6-76060006-generic
11:33:45 [daemon(36341)] [INFO] watching for changes in path: "/home/dustin/.config/espanso"
11:33:45 [daemon(36341)] [INFO] espanso version: 2.1.8
11:33:45 [daemon(36341)] [INFO] spawning the worker process...
11:33:45 [daemon(36341)] [INFO] binded to IPC unix socket: /home/dustin/.cache/espanso/espansodaemonv2.sock
11:33:45 [worker(36349)] [INFO] reading configs from: "/home/dustin/.config/espanso"
11:33:45 [worker(36349)] [INFO] reading packages from: "/home/dustin/.config/espanso/match/packages"
11:33:45 [worker(36349)] [INFO] using runtime dir: "/home/dustin/.cache/espanso"
11:33:45 [worker(36349)] [INFO] system info: Pop!_OS v22.04 - kernel: 6.0.6-76060006-generic
11:33:45 [worker(36349)] [INFO] binded to IPC unix socket: /home/dustin/.cache/espanso/espansoworkerv2.sock
11:33:45 [worker(36349)] [INFO] using X11AppInfoProvider
11:33:45 [worker(36349)] [INFO] monitoring the status of the daemon process
11:33:45 [worker(36349)] [INFO] using X11Source
11:33:45 [worker(36349)] [INFO] using X11ProxyInjector
11:33:45 [worker(36349)] [INFO] using X11Clipboard
11:35:19 [daemon(36341)] [INFO] configuration change detected, restarting worker process...
11:35:19 [worker(36349)] [INFO] engine eventloop has terminated, propagating exit event...
11:35:19 [worker(36349)] [INFO] waiting for engine exit mode...
11:35:19 [worker(36349)] [INFO] exiting worker process...
11:35:19 [daemon(36341)] [INFO] spawning the worker process...
11:35:19 [worker(36692)] [INFO] reading configs from: "/home/dustin/.config/espanso"
11:35:19 [worker(36692)] [INFO] reading packages from: "/home/dustin/.config/espanso/match/packages"
11:35:19 [worker(36692)] [INFO] using runtime dir: "/home/dustin/.cache/espanso"
11:35:19 [worker(36692)] [INFO] system info: Pop!_OS v22.04 - kernel: 6.0.6-76060006-generic
11:35:19 [worker(36692)] [INFO] binded to IPC unix socket: /home/dustin/.cache/espanso/espansoworkerv2.sock
11:35:19 [worker(36692)] [INFO] using X11AppInfoProvider
11:35:19 [worker(36692)] [INFO] monitoring the status of the daemon process
11:35:19 [worker(36692)] [INFO] using X11Source
11:35:19 [worker(36692)] [INFO] using X11ProxyInjector
11:35:19 [worker(36692)] [INFO] using X11Clipboard
11:45:06 [daemon(36341)] [INFO] configuration change detected, restarting worker process...
11:45:06 [worker(36692)] [INFO] engine eventloop has terminated, propagating exit event...
11:45:06 [worker(36692)] [INFO] waiting for engine exit mode...
11:45:06 [worker(36692)] [INFO] exiting worker process...
11:45:06 [daemon(36341)] [INFO] spawning the worker process...
11:45:06 [worker(38322)] [INFO] reading configs from: "/home/dustin/.config/espanso"
11:45:06 [worker(38322)] [INFO] reading packages from: "/home/dustin/.config/espanso/match/packages"
11:45:06 [worker(38322)] [INFO] using runtime dir: "/home/dustin/.cache/espanso"
11:45:06 [worker(38322)] [INFO] system info: Pop!_OS v22.04 - kernel: 6.0.6-76060006-generic
11:45:06 [worker(38322)] [INFO] binded to IPC unix socket: /home/dustin/.cache/espanso/espansoworkerv2.sock
11:45:06 [worker(38322)] [INFO] using X11AppInfoProvider
11:45:06 [worker(38322)] [INFO] monitoring the status of the daemon process
11:45:06 [worker(38322)] [INFO] using X11Source
11:45:06 [worker(38322)] [INFO] using X11ProxyInjector
11:45:06 [worker(38322)] [INFO] using X11Clipboard
11:45:28 [daemon(36341)] [INFO] configuration change detected, restarting worker process...
11:45:28 [worker(38322)] [INFO] engine eventloop has terminated, propagating exit event...
11:45:28 [worker(38322)] [INFO] waiting for engine exit mode...
11:45:28 [worker(38322)] [INFO] exiting worker process...
11:45:28 [daemon(36341)] [INFO] spawning the worker process...
11:45:28 [worker(38418)] [INFO] reading configs from: "/home/dustin/.config/espanso"
11:45:28 [worker(38418)] [INFO] reading packages from: "/home/dustin/.config/espanso/match/packages"
11:45:28 [worker(38418)] [INFO] using runtime dir: "/home/dustin/.cache/espanso"
11:45:28 [worker(38418)] [INFO] system info: Pop!_OS v22.04 - kernel: 6.0.6-76060006-generic
11:45:28 [worker(38418)] [INFO] binded to IPC unix socket: /home/dustin/.cache/espanso/espansoworkerv2.sock
11:45:28 [worker(38418)] [INFO] using X11AppInfoProvider
11:45:28 [worker(38418)] [INFO] monitoring the status of the daemon process
11:45:28 [worker(38418)] [INFO] using X11Source
11:45:28 [worker(38418)] [INFO] using X11ProxyInjector
11:45:28 [worker(38418)] [INFO] using X11Clipboard

Setup information

I suspect it might be the way escaping is handled. Either in Espanso or Kitty? (Total guess).

Thank you so much!

thedward commented 1 year ago

I get the same bug with kitty version 0.27.1, on Debian 11

bashfulrobot commented 1 year ago

I have replicated the same issue on wezterm. I will adjust the title to reflect for future searches.

jwigg-netscout commented 1 year ago

do you know if you're using Wayland? If so, you may need to adjust the evdev_modifier_delay config option, as noted in the documentation

bashfulrobot commented 1 year ago

I am not using Wayland on this system. πŸ‘

jwigg-netscout commented 1 year ago

I was afraid you'd say that πŸ™

So, I've taken a closer look at your report, and I think it's actually 2 separate issues:

Your first example is below the default clipboard_threshold, which is 100 characters. Below that threshold, expansions are inserted with SendKeys; above, it they are pasted using the clipboard. I'm pretty sure that explains the 2 different behaviors you're seeing: incorrect keys being sent in the first example, and incorrect paste shortcut in the second example.

I'm not positive how to fix the first one; increasing the inject_delay or key_delay settings may help. You could also try disable_x11_fast_inject though based on the notes in the docs, I suspect that even if it works, you won't like it.

For the second example, I think that creating an App-specific configuration with paste_shortcut set to whatever Wezterm and Kitty expect will fix it (probably SHIFT+INSERT)

bashfulrobot commented 1 year ago

So let me ask you this, why would it work on some terminals? IE - gnome-terminal, tilix, etc? I suspect it is something the terminals are setting. πŸ€”

jwigg-netscout commented 1 year ago

Yeah, no clue. It's got to be something that the terminals are doing differently, but I'm in no way qualified to guess at what.

jwigg-netscout commented 1 year ago

Possibly relevant: #1088 ?

jpmvferreira commented 1 year ago

I think this is related to #1288, where several users reported that "v" was being pasted instead of the actual snippet. Most users seem to be running MacOS, with one reporting this would take place in Kitty but not in Alactritty, whereas the other reported this also taking place in Alacritty. I'm running Kitty on Manjaro Linux, latest updates as of today, and it happens only in Kitty but not in Alactritty.

snuffop commented 1 year ago

I have a bit more info from testing.
Using backend: Clipboard :espanso results v Using Inject or Auto :espanso results Hi there!

YET! Using backend: Clipboard (Kitty Arch-linux) ttime results v Using backend: Inject or Auto (Kitty Arch-linux) ttime results
09;45 expected and configured result should be and is everywhere else 09:45

smeech commented 9 months ago

Many of these problems can now be resolved by testing force_mode: for individual triggers (often hinting at required changes in the backend: globally or in app-specific configurations), and occasionally with other options. Have you tried those?

lyz-code commented 6 months ago

I can reproduce the same errors as @snuffop on kitty.

@smeech the force_mode does not solve the issue because no backend gives the correct output (one outputs v while the other outputs 09;45 instead of 09:45).

I've made it work by setting the disable_x11_fast_inject: true configuration, but it's quite sloppy so I'd rather not use it.