Skip to content

Commit

Permalink
fix hotstrings containing the trigger char itself, e.g. `btw::by the …
Browse files Browse the repository at this point in the history
…way` didn't properly send the first space
  • Loading branch information
phil294 committed Jul 20, 2023
1 parent 1832377 commit 06d98ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/run/display/hotstring.cr
Expand Up @@ -37,14 +37,20 @@ module Run
other_keysyms.join[...other_size].downcase == @abbrev.downcase
end
end
def trigger(runner)
if @automatic_backspacing
runner.display.pause do
def trigger(runner, end_char_key_event = nil)
runner.display.pause do
if @automatic_backspacing
(@abbrev.size + (@immediate ? 0 : 1)).times do
runner.display.x_do.keys "BackSpace", delay: 0
sleep @delay.milliseconds if @delay != -1
end
end
if end_char_key_event
# Same xdotool workaround as in send.cr
end_char_key_up = XDo::LibXDo::Charcodemap.new
end_char_key_up.code = end_char_key_event.keycode
runner.display.x_do.keys_raw [end_char_key_up], pressed: false, delay: 0
end
end

runner.add_thread @cmd.not_nil!, @label, @priority
Expand Down
2 changes: 1 addition & 1 deletion src/run/display/hotstrings.cr
Expand Up @@ -53,7 +53,7 @@ module Run
@key_buff_i = 0_u8
if ! prev_candidate.nil?
@runner.set_global_built_in_static_var("A_EndChar", char.to_s)
prev_candidate.trigger(@runner)
prev_candidate.trigger(@runner, end_char_key_event: key_event)
end
else
@key_buff_i = 0_u8 if @key_buff_i > 29
Expand Down

0 comments on commit 06d98ff

Please sign in to comment.