Skip to content

Commit

Permalink
Merge pull request #130 from ndsizeif/keytable
Browse files Browse the repository at this point in the history
Add methods to track and restore key-table
  • Loading branch information
Morantron authored Oct 30, 2024
2 parents 0f2d8b9 + 7f6a019 commit c257f93
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/fingers/commands/start.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module Fingers::Commands

class Start < Cling::Command
@original_options : Hash(String, String) = {} of String => String
@last_key_table : String = "root"
@last_pane_id : String | Nil
@mode : String = "default"
@pane_id : String = ""
Expand Down Expand Up @@ -66,6 +67,7 @@ module Fingers::Commands
end

track_options_to_restore
track_last_key_table
track_last_pane
show_hints

Expand Down Expand Up @@ -118,6 +120,15 @@ module Fingers::Commands
end
end

private def restore_last_key_table
tmux.set_key_table(@last_key_table)
end

private def track_last_key_table
last_key_table = tmux.exec("display-message -p '\#{client_key_table}'").chomp
@last_key_table = last_key_table unless last_key_table.empty?
end

private def restore_last_pane
tmux.select_pane(@last_pane_id)
select_active_pane
Expand Down Expand Up @@ -180,12 +191,11 @@ module Fingers::Commands
end

private def teardown
tmux.set_key_table "root"

tmux.swap_panes(fingers_pane_id, target_pane.pane_id)
tmux.kill_pane(fingers_pane_id)

restore_last_pane
restore_last_key_table
restore_options

view.run_action if state.result
Expand Down

0 comments on commit c257f93

Please sign in to comment.