Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua
http://www.hammerspoon.org
MIT License
11.83k stars 578 forks source link

hs.chooser block input method #3056

Open KURANADO2 opened 2 years ago

KURANADO2 commented 2 years ago

I used hs.chooser to realize the emoji picture search:

emoji

When I use chinese Input Method to input n i h a o(that means chinese 'hello'),I found the Input Method blocked by hs.chooser search box:

WX20211228-224427@2x

But that doesn't always happen,Sometimes it works properly:

WechatIMG287

I don't know how to solve this problem,Can someone give me a hand?

This is my code link:https://github.com/KURANADO2/hammerspoon-kuranado/blob/main/modules/emoji.lua

luckman212 commented 2 years ago

Hi @KURANADO2 Your chooser looks very cool! Sorry I don't know how to fix your issue but my general suggestion would be to add some console logging to your module to figure out where it's stalling or failing.

Also, can I ask what you're using for your custom Terminal prompt / git prompt? Looks amazing.

latenitefilms commented 2 years ago

Maybe try wrapping the callback function with a hs.timer.doAfter() to attempt to avoid any lockups?

KURANADO2 commented 2 years ago

@luckman212

Thanks! I will print some log to figure this problem!

Also, my terminal is oh-my-zsh, ZSH_THEME is agnoster. After installing oh-my-zsh,modify the ~/.zshrc file:

ZSH_THEME="agnoster"
plugins=(git)

Maybe you should install Meslo LG M Regular for Powerline fonts to solve the garble problem.

KURANADO2 commented 2 years ago

@latenitefilms Sorry, I'm not sure hs.timer.doAfter() should be added to which callback function.

I tried other language input methods that come with the system, and they all have this problem, but Google Japanese Input Method does not have this problem.

latenitefilms commented 2 years ago

Maybe try something like this:

chooser:queryChangedCallback(function()
    hs.timer.doAfter(0.1, function()
       local query = chooser:query()
       page = 1
       request(query)
    end)
end)